From 8e383577374ead236cdaf75d53dc2356b8b0cec8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=B7=8D?= Date: Fri, 14 Jun 2024 16:59:24 +0800 Subject: [PATCH] fix: cast_primitive data type (#354) * fix: cast_primitive data type * ci: fix modern OS's docker compose version ref: https://askubuntu.com/questions/1508129/docker-compose-giving-containerconfig-errors-after-update-today * ci: adapt new docker compose naming * make linter happy --------- Co-authored-by: Wey Gu --- .github/workflows/run_test.yaml | 6 +++--- nebula3/data/DataObject.py | 2 +- tests/test_pool.py | 4 ++-- tests/test_session.py | 12 ++++++++---- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/.github/workflows/run_test.yaml b/.github/workflows/run_test.yaml index 82c6c5df..48681e91 100644 --- a/.github/workflows/run_test.yaml +++ b/.github/workflows/run_test.yaml @@ -70,12 +70,12 @@ jobs: run: pdm fmt-check - name: Test with pytest run: | - docker-compose -f tests/docker-compose.yaml up -d + docker compose -f tests/docker-compose.yaml up -d sleep 20 pdm test - name: Test SSL connection with pytest run: | - enable_ssl=true docker-compose -f tests/docker-compose-ssl.yaml up -d + enable_ssl=true docker compose -f tests/docker-compose-ssl.yaml up -d sleep 20 pdm test-ssl - name: Upload Coverage to Codecov @@ -101,7 +101,7 @@ jobs: pip install prettytable pandas - name: Setup containers run: | - docker-compose -f tests/docker-compose.yaml up -d + docker compose -f tests/docker-compose.yaml up -d sleep 20 - name: Test example run: | diff --git a/nebula3/data/DataObject.py b/nebula3/data/DataObject.py index df86118e..838ac270 100644 --- a/nebula3/data/DataObject.py +++ b/nebula3/data/DataObject.py @@ -745,7 +745,7 @@ def _cast_primitive(raw_value): return {k: _cast_primitive(v) for k, v in raw_value.as_map().items()} elif _type == Value.TVAL: return raw_value.as_time().get_local_time_str() - elif _type == Value.DTVAL: + elif _type == Value.DVAL: return raw_value.as_date().__repr__() elif _type == Value.DTVAL: return raw_value.as_datetime().get_local_datetime_str() diff --git a/tests/test_pool.py b/tests/test_pool.py index e61f2daf..531aa599 100644 --- a/tests/test_pool.py +++ b/tests/test_pool.py @@ -283,7 +283,7 @@ def test_remove_invalid_connection(): assert pool.init(addresses, configs) # turn down one server('127.0.0.1', 9669) so the connection to it is invalid - os.system("docker stop tests_graphd0_1") + os.system("docker stop tests_graphd0_1 || docker stop tests-graphd0-1") time.sleep(3) # get connection from the pool, we should be able to still get 30 connections even though one server is down @@ -302,5 +302,5 @@ def test_remove_invalid_connection(): assert len(pool._connections[addresses[2]]) == 15 finally: - os.system("docker start tests_graphd0_1") + os.system("docker start tests_graphd0_1 || docker start tests-graphd0-1") time.sleep(3) diff --git a/tests/test_session.py b/tests/test_session.py index 4bf0942a..7485facc 100644 --- a/tests/test_session.py +++ b/tests/test_session.py @@ -50,8 +50,12 @@ def test_2_reconnect(self): time.sleep(10) for i in range(0, 5): if i == 3: - os.system("docker stop tests_graphd0_1") - os.system("docker stop tests_graphd1_1") + os.system( + "docker stop tests_graphd0_1 || docker stop tests-graphd0-1" + ) + os.system( + "docker stop tests_graphd1_1 || docker stop tests-graphd1-1" + ) time.sleep(3) resp = session.execute("SHOW SESSIONS") assert resp.is_succeeded(), resp.error_msg() @@ -63,8 +67,8 @@ def test_2_reconnect(self): except Exception as e: assert False, e finally: - os.system("docker start tests_graphd0_1") - os.system("docker start tests_graphd1_1") + os.system("docker start tests_graphd0_1 || docker start tests-graphd0-1") + os.system("docker start tests_graphd1_1 || docker start tests-graphd1-1") time.sleep(2) def test_3_session_context(self):