From 4687cad425bb8245579e41d9e76e4523dd70353b Mon Sep 17 00:00:00 2001 From: Yee <2520865+yixinglu@users.noreply.github.com> Date: Thu, 15 Oct 2020 19:04:07 +0800 Subject: [PATCH] Improve tests with pytest fixture (#321) * Improve test with pytest fixture Format Simplify * refactor class fixture * Replace CommonTtypes with ttypes Extract fill_ve function Fix plan node name typo Try to fix checkout action * Fix path test failure * Try to close socket --- src/planner/PlanNode.cpp | 16 +- tests/common/nebula_service.py | 8 +- tests/common/nebula_test_suite.py | 228 +------------------------ tests/query/conftest.py | 255 ++++++++++++++++++++++++++++ tests/query/v1/test_find_path.py | 28 +-- tests/query/v1/test_yield.py | 5 +- tests/query/v2/test_get_subgraph.py | 79 ++++----- 7 files changed, 321 insertions(+), 298 deletions(-) create mode 100644 tests/query/conftest.py diff --git a/src/planner/PlanNode.cpp b/src/planner/PlanNode.cpp index a91b0c9df74..26dc7990ea6 100644 --- a/src/planner/PlanNode.cpp +++ b/src/planner/PlanNode.cpp @@ -83,21 +83,21 @@ const char* PlanNode::toString(PlanNode::Kind kind) { case Kind::kAlterEdge: return "AlterEdge"; case Kind::kCreateTagIndex: - return "kCreateTagIndex"; + return "CreateTagIndex"; case Kind::kCreateEdgeIndex: - return "kCreateEdgeIndex"; + return "CreateEdgeIndex"; case Kind::kDropTagIndex: - return "kDropTagIndex"; + return "DropTagIndex"; case Kind::kDropEdgeIndex: - return "kDropEdgeIndex"; + return "DropEdgeIndex"; case Kind::kDescTagIndex: - return "kDescTagIndex"; + return "DescTagIndex"; case Kind::kDescEdgeIndex: - return "kDescEdgeIndex"; + return "DescEdgeIndex"; case Kind::kRebuildTagIndex: - return "kRebuildTagIndex"; + return "RebuildTagIndex"; case Kind::kRebuildEdgeIndex: - return "kRebuildEdgeIndex"; + return "RebuildEdgeIndex"; case Kind::kInsertVertices: return "InsertVertices"; case Kind::kInsertEdges: diff --git a/tests/common/nebula_service.py b/tests/common/nebula_service.py index 2e8f5ff5022..0f1a36bc13e 100644 --- a/tests/common/nebula_service.py +++ b/tests/common/nebula_service.py @@ -78,10 +78,10 @@ def _find_free_port(self): return ports def _telnet_port(self, port): - sk = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - sk.settimeout(1) - result = sk.connect_ex(('127.0.0.1', port)) - return result == 0 + with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as sk: + sk.settimeout(1) + result = sk.connect_ex(('127.0.0.1', port)) + return result == 0 def install(self): os.mkdir(self.work_dir) diff --git a/tests/common/nebula_test_suite.py b/tests/common/nebula_test_suite.py index b1d2d530b4a..c80b01f20da 100644 --- a/tests/common/nebula_test_suite.py +++ b/tests/common/nebula_test_suite.py @@ -57,33 +57,6 @@ def setup_class(self): self.set_delay() self.prepare() - @classmethod - def load_vertex_edge(self): - self.VERTEXS = dict() - self.EDGES = dict() - nba_file = self.data_dir + '/data/nba.ngql' - print("load will open ", nba_file) - with open(nba_file, 'r') as data_file: - lines = data_file.readlines() - ddl = False - dataType = ['none'] - for line in lines: - strip_line = line.strip() - if len(strip_line) == 0: - continue - elif strip_line.startswith('--'): - comment = strip_line[2:] - if comment == 'DDL': - ddl = True - elif comment == 'END': - if ddl: - ddl = False - else: - if not ddl: - self.parse_line(line.strip(), dataType) - if line.endswith(';'): - dataType[0] = 'none' - @classmethod def load_data(self): self.data_loaded = True @@ -433,7 +406,7 @@ def check_result(self, resp, expect, ignore_col: Set[int] = set(), is_regex=Fals if resp.data is None: assert False, 'resp.data is None' rows = resp.data.rows - + msg = 'len(rows)[%d] != len(expect)[%d]' % (len(rows), len(expect)) assert len(rows) == len(expect), msg @@ -642,204 +615,6 @@ def check_error_msg(self, resp, expect): else: assert err_msg == expect, msg - @classmethod - def parse_line(self, line, dataType): - if line.startswith('INSERT') or line.startswith('VALUES'): - return '' - - if line.startswith('VERTEX player'): - dataType[0] = 'player' - elif line.startswith('VERTEX team'): - dataType[0] = 'team' - elif line.startswith('VERTEX bachelor'): - dataType[0] = 'bachelor' - elif line.startswith('EDGE serve'): - dataType[0] = 'serve' - elif line.startswith('EDGE like'): - dataType[0] = 'like' - elif line.startswith('EDGE teammate'): - dataType[0] = 'teammate' - else: - line = re.split(':|,|->', line.strip(',; \t')) - line = list(map(lambda i: i.strip(' ()"'), line)) - value = CommonTtypes.Value() - if dataType[0] == 'none': - assert False - elif dataType[0] == 'player': - vertex = self.create_vertex_player(line) - key = str(vertex.vid, encoding='utf-8') - if key in self.VERTEXS: - temp = self.VERTEXS[key].get_vVal() - temp.tags.append(vertex.tags[0]) - temp.tags.sort(key=lambda x : x.name) - value.set_vVal(temp) - self.VERTEXS[key] = value - else: - value.set_vVal(vertex) - self.VERTEXS[key] = value - elif dataType[0] == 'team': - vertex = self.create_vertex_team(line) - value.set_vVal(vertex) - key = str(vertex.vid, encoding = 'utf-8') - self.VERTEXS[key] = value - elif dataType[0] == 'bachelor': - vertex = self.create_vertex_bachelor(line) - key = str(vertex.vid, encoding = 'utf-8') - if key in self.VERTEXS: - temp = self.VERTEXS[key].get_vVal() - temp.tags.append(vertex.tags[0]) - temp.tags.sort(key=lambda x : x.name) - value.set_vVal(temp) - self.VERTEXS[key] = value - else: - value.set_vVal(vertex) - self.VERTEXS[key] = value - elif dataType[0] == 'serve': - edge = self.create_edge_serve(line) - value.set_eVal(edge) - key = str(edge.src, encoding = 'utf-8') + str(edge.dst, encoding = 'utf-8') + str(edge.name, encoding = 'utf-8') + str(edge.ranking) - self.EDGES[key] = value - elif dataType[0] == 'like': - edge = self.create_edge_like(line) - value.set_eVal(edge) - key = str(edge.src, encoding = 'utf-8') + str(edge.dst, encoding = 'utf-8') + str(edge.name, encoding = 'utf-8') + str(edge.ranking) - self.EDGES[key] = value - elif dataType[0] == 'teammate': - edge = self.create_edge_teammate(line) - value.set_eVal(edge) - key = str(edge.src, encoding = 'utf-8') + str(edge.dst, encoding = 'utf-8') + str(edge.name, encoding = 'utf-8') + str(edge.ranking) - self.EDGES[key] = value - else: - assert False - - @classmethod - def create_vertex_player(self, line): - if len(line) != 3: - assert False - - vertex = CommonTtypes.Vertex() - vertex.vid = bytes(line[0], encoding = 'utf-8') - tags = [] - tag = CommonTtypes.Tag() - tag.name = bytes('player', encoding = 'utf-8') - - props = dict() - name = CommonTtypes.Value() - name.set_sVal(bytes(line[1], encoding = 'utf-8')) - props[bytes('name', encoding = 'utf-8')] = name - age = CommonTtypes.Value() - age.set_iVal(int(line[2])) - props[bytes('age', encoding = 'utf-8')] = age - tag.props = props - tags.append(tag) - vertex.tags = tags - return vertex - - @classmethod - def create_vertex_team(self, line): - if len(line) != 2: - assert False - vertex = CommonTtypes.Vertex() - vertex.vid = bytes(line[0], encoding = 'utf-8') - tags = [] - tag = CommonTtypes.Tag() - tag.name = bytes('team', encoding = 'utf-8') - - props = dict() - name = CommonTtypes.Value() - name.set_sVal(bytes(line[1], encoding = 'utf-8')) - props[bytes('name', encoding = 'utf-8')] = name - tag.props = props - tags.append(tag) - vertex.tags = tags - return vertex - - @classmethod - def create_vertex_bachelor(self, line): - if len(line) != 3: - assert False - - vertex = CommonTtypes.Vertex() - vertex.vid = bytes(line[0], encoding = 'utf-8') - tags = [] - tag = CommonTtypes.Tag() - tag.name = bytes('bachelor', encoding = 'utf-8') - - props = dict() - name = CommonTtypes.Value() - name.set_sVal(bytes(line[1], encoding = 'utf-8')) - props[bytes('name', encoding = 'utf-8')] = name - speciality = CommonTtypes.Value() - speciality.set_sVal(bytes(line[2], encoding = 'utf-8')) - props[bytes('speciality', encoding = 'utf-8')] = speciality - tag.props = props - tags.append(tag) - vertex.tags = tags - return vertex - - @classmethod - def create_edge_serve(self, line): - if len(line) != 4: - assert False - edge = CommonTtypes.Edge() - edge.src = bytes(line[0], encoding = 'utf-8') - if '@' in line[1]: - temp = list(map(lambda i: i.strip('"'), re.split('@', line[1]))) - edge.dst = bytes(temp[0], encoding = 'utf-8') - edge.ranking = int(temp[1]) - else: - edge.dst = bytes(line[1], encoding = 'utf-8') - edge.ranking = 0 - edge.type = 1 - edge.name = bytes('serve', encoding = 'utf-8') - props = dict() - start_year = CommonTtypes.Value() - start_year.set_iVal(int(line[2])) - end_year = CommonTtypes.Value() - end_year.set_iVal(int(line[3])) - props[bytes('start_year', encoding = 'utf-8')] = start_year - props[bytes('end_year', encoding = 'utf-8')] = end_year - edge.props = props - return edge - - @classmethod - def create_edge_like(self, line): - if len(line) != 3: - assert False - edge = CommonTtypes.Edge() - - edge.src = bytes(line[0], encoding = 'utf-8') - edge.dst = bytes(line[1], encoding = 'utf-8') - edge.type = 1 - edge.ranking = 0 - edge.name = bytes('like', encoding = 'utf-8') - props = dict() - likeness = CommonTtypes.Value() - likeness.set_iVal(int(line[2])) - props[bytes('likeness', encoding = 'utf-8')] = likeness - edge.props = props - return edge - - @classmethod - def create_edge_teammate(self, line): - if len(line) != 4: - assert False - edge = CommonTtypes.Edge() - edge.src = bytes(line[0], encoding = 'utf-8') - edge.dst = bytes(line[1], encoding = 'utf-8') - edge.type = 1 - edge.ranking = 0 - edge.name = bytes('teammate', encoding = 'utf-8') - props = dict() - start_year = CommonTtypes.Value() - start_year.set_iVal(int(line[2])) - end_year = CommonTtypes.Value() - end_year.set_iVal(int(line[3])) - props[bytes('start_year', encoding = 'utf-8')] = start_year - props[bytes('end_year', encoding = 'utf-8')] = end_year - edge.props = props - return edge - @classmethod def check_exec_plan(cls, resp, expect): cls.check_resp_succeeded(resp) @@ -873,4 +648,3 @@ def diff_plan_node(cls, plan_desc, line_num, expect, expect_idx): for i in range(len(plan_node_desc.dependencies)): line_num = plan_desc.node_index_map[plan_node_desc.dependencies[i]] cls.diff_plan_node(plan_desc, line_num, expect, expect_node[1][i]) - diff --git a/tests/query/conftest.py b/tests/query/conftest.py new file mode 100644 index 00000000000..e43f738dc0f --- /dev/null +++ b/tests/query/conftest.py @@ -0,0 +1,255 @@ +# --coding:utf-8-- +# +# Copyright (c) 2020 vesoft inc. All rights reserved. +# +# This source code is licensed under Apache 2.0 License, +# attached with Common Clause Condition 1.0, found in the LICENSES directory. + +import re +import pytest + +from nebula2.common import ttypes + + +def edgekey(edge): + return utf8s(edge.src) + utf8s(edge.dst) + utf8s(edge.name) \ + + str(edge.ranking) + + +def utf8b(s: str): + return bytes(s, encoding='utf-8') + + +def utf8s(b): + return str(b, encoding='utf-8') + + +def create_vertex_team(line): + assert len(line) == 2 + vertex = ttypes.Vertex() + vertex.vid = utf8b(line[0]) + tags = [] + tag = ttypes.Tag() + tag.name = utf8b('team') + + props = dict() + name = ttypes.Value() + name.set_sVal(utf8b(line[1])) + props[utf8b('name')] = name + tag.props = props + tags.append(tag) + vertex.tags = tags + return vertex + + +def create_vertex_player(line): + assert len(line) == 3 + vertex = ttypes.Vertex() + vertex.vid = utf8b(line[0]) + tags = [] + tag = ttypes.Tag() + tag.name = utf8b('player') + + props = dict() + name = ttypes.Value() + name.set_sVal(utf8b(line[1])) + props[utf8b('name')] = name + age = ttypes.Value() + age.set_iVal(int(line[2])) + props[utf8b('age')] = age + tag.props = props + tags.append(tag) + vertex.tags = tags + return vertex + + +def create_vertex_bachelor(line): + assert len(line) == 3 + vertex = ttypes.Vertex() + vertex.vid = utf8b(line[0]) + tags = [] + tag = ttypes.Tag() + tag.name = utf8b('bachelor') + + props = dict() + name = ttypes.Value() + name.set_sVal(utf8b(line[1])) + props[utf8b('name')] = name + speciality = ttypes.Value() + speciality.set_sVal(utf8b(line[2])) + props[utf8b('speciality')] = speciality + tag.props = props + tags.append(tag) + vertex.tags = tags + return vertex + + +def create_edge_serve(line): + assert len(line) == 4 + edge = ttypes.Edge() + edge.src = utf8b(line[0]) + if '@' in line[1]: + temp = list(map(lambda i: i.strip('"'), re.split('@', line[1]))) + edge.dst = utf8b(temp[0]) + edge.ranking = int(temp[1]) + else: + edge.dst = utf8b(line[1]) + edge.ranking = 0 + edge.type = 1 + edge.name = utf8b('serve') + props = dict() + start_year = ttypes.Value() + start_year.set_iVal(int(line[2])) + end_year = ttypes.Value() + end_year.set_iVal(int(line[3])) + props[utf8b('start_year')] = start_year + props[utf8b('end_year')] = end_year + edge.props = props + return edge + + +def create_edge_like(line): + assert len(line) == 3 + edge = ttypes.Edge() + + edge.src = utf8b(line[0]) + edge.dst = utf8b(line[1]) + edge.type = 1 + edge.ranking = 0 + edge.name = utf8b('like') + props = dict() + likeness = ttypes.Value() + likeness.set_iVal(int(line[2])) + props[utf8b('likeness')] = likeness + edge.props = props + return edge + + +def create_edge_teammate(line): + assert len(line) == 4 + edge = ttypes.Edge() + edge.src = utf8b(line[0]) + edge.dst = utf8b(line[1]) + edge.type = 1 + edge.ranking = 0 + edge.name = utf8b('teammate') + props = dict() + start_year = ttypes.Value() + start_year.set_iVal(int(line[2])) + end_year = ttypes.Value() + end_year.set_iVal(int(line[3])) + props[utf8b('start_year')] = start_year + props[utf8b('end_year')] = end_year + edge.props = props + return edge + + +def get_datatype(line): + if line.startswith('VERTEX player'): + return 'player' + elif line.startswith('VERTEX team'): + return 'team' + elif line.startswith('VERTEX bachelor'): + return 'bachelor' + elif line.startswith('EDGE serve'): + return 'serve' + elif line.startswith('EDGE like'): + return 'like' + elif line.startswith('EDGE teammate'): + return 'teammate' + return None + + +def fill_ve(line, datatype: str, VERTEXS, EDGES): + line = re.split(':|,|->', line.strip(',; \t')) + line = list(map(lambda i: i.strip(' ()"'), line)) + value = ttypes.Value() + assert datatype != 'none' + if datatype == 'player': + vertex = create_vertex_player(line) + key = utf8s(vertex.vid) + if key in VERTEXS: + temp = VERTEXS[key].get_vVal() + temp.tags.append(vertex.tags[0]) + temp.tags.sort(key=lambda x: x.name) + value.set_vVal(temp) + VERTEXS[key] = value + else: + value.set_vVal(vertex) + VERTEXS[key] = value + elif datatype == 'team': + vertex = create_vertex_team(line) + value.set_vVal(vertex) + key = utf8s(vertex.vid) + VERTEXS[key] = value + elif datatype == 'bachelor': + vertex = create_vertex_bachelor(line) + key = utf8s(vertex.vid) + if key in VERTEXS: + temp = VERTEXS[key].get_vVal() + temp.tags.append(vertex.tags[0]) + temp.tags.sort(key=lambda x: x.name) + value.set_vVal(temp) + VERTEXS[key] = value + else: + value.set_vVal(vertex) + VERTEXS[key] = value + elif datatype == 'serve': + edge = create_edge_serve(line) + value.set_eVal(edge) + key = edgekey(edge) + EDGES[key] = value + elif datatype == 'like': + edge = create_edge_like(line) + value.set_eVal(edge) + key = edgekey(edge) + EDGES[key] = value + elif datatype == 'teammate': + edge = create_edge_teammate(line) + value.set_eVal(edge) + key = edgekey(edge) + EDGES[key] = value + else: + raise ValueError('datatype is {}'.format(datatype)) + + +def parse_line(line, dataType, VERTEXS, EDGES): + if line.startswith('INSERT') or line.startswith('VALUES'): + return '' + + dt = get_datatype(line) + if dt is not None: + dataType[0] = dt + else: + fill_ve(line, dataType[0], VERTEXS, EDGES) + + +@pytest.fixture(scope="class") +def set_vertices_and_edges(request): + VERTEXS = {} + EDGES = {} + nba_file = request.cls.data_dir + '/data/nba.ngql' + print("load will open ", nba_file) + with open(nba_file, 'r') as data_file: + lines = data_file.readlines() + ddl = False + dataType = ['none'] + for line in lines: + strip_line = line.strip() + if len(strip_line) == 0: + continue + elif strip_line.startswith('--'): + comment = strip_line[2:] + if comment == 'DDL': + ddl = True + elif comment == 'END': + if ddl: + ddl = False + else: + if not ddl: + parse_line(line.strip(), dataType, VERTEXS, EDGES) + if line.endswith(';'): + dataType[0] = 'none' + + request.cls.VERTEXS = VERTEXS + request.cls.EDGES = EDGES diff --git a/tests/query/v1/test_find_path.py b/tests/query/v1/test_find_path.py index 737e242e745..84e3fb1035b 100644 --- a/tests/query/v1/test_find_path.py +++ b/tests/query/v1/test_find_path.py @@ -5,24 +5,24 @@ # This source code is licensed under Apache 2.0 License, # attached with Common Clause Condition 1.0, found in the LICENSES directory. +import pytest + from tests.common.nebula_test_suite import NebulaTestSuite + +@pytest.mark.usefixtures('set_vertices_and_edges') class TestFindPath(NebulaTestSuite): @classmethod def prepare(self): self.use_nba() - self.load_vertex_edge() - - def cleanup(): - pass def test_single_pair_constant_input(self): stmt = 'FIND SHORTEST PATH FROM "Tim Duncan" TO "Tony Parker" OVER like' resp = self.execute_query(stmt) self.check_resp_succeeded(resp) expected_data = { - "column_names" : ["_path"], - "rows" : [ + "column_names": ["_path"], + "rows": [ [b"Tim Duncan", (b"like", 0, b"Tony Parker")] ] } @@ -33,8 +33,8 @@ def test_single_pair_constant_input(self): resp = self.execute_query(stmt) self.check_resp_succeeded(resp) expected_data = { - "column_names" : ["_path"], - "rows" : [ + "column_names": ["_path"], + "rows": [ [b"Tim Duncan", (b"like", 0, b"Tony Parker"), (b"like", 0, b"LaMarcus Aldridge")] ] } @@ -45,8 +45,8 @@ def test_single_pair_constant_input(self): resp = self.execute_query(stmt) self.check_resp_succeeded(resp) expected_data = { - "column_names" : ["_path"], - "rows" : [ + "column_names": ["_path"], + "rows": [ [b"Tiago Splitter", (b"like", 0, b"Tim Duncan"), (b"like", 0, b"Tony Parker"), (b"like", 0, b"LaMarcus Aldridge")] ] } @@ -57,8 +57,8 @@ def test_single_pair_constant_input(self): resp = self.execute_query(stmt) self.check_resp_succeeded(resp) expected_data = { - "column_names" : ["_path"], - "rows" : [ + "column_names": ["_path"], + "rows": [ [b"Tiago Splitter", (b"like", 0, b"Tim Duncan"), (b"teammate", 0, b"LaMarcus Aldridge")] ] } @@ -69,8 +69,8 @@ def test_single_pair_constant_input(self): resp = self.execute_query(stmt) self.check_resp_succeeded(resp) expected_data = { - "column_names" : ["_path"], - "rows" : [ + "column_names": ["_path"], + "rows": [ [b"Tiago Splitter", (b"like", 0, b"Tim Duncan"), (b"teammate", 0, b"LaMarcus Aldridge")] ] } diff --git a/tests/query/v1/test_yield.py b/tests/query/v1/test_yield.py index 6e819e0cce5..0082cc4626a 100644 --- a/tests/query/v1/test_yield.py +++ b/tests/query/v1/test_yield.py @@ -151,12 +151,11 @@ def test_logic_2(self): expect_result = [[3]] self.check_result(resp, expect_result) - @pytest.mark.skip(reason="") def test_in_call(self): - query = 'YIELD udf_is_in(1,0,1,2), 123' + query = 'YIELD 1 IN [0,1,2], 123' resp = self.execute_query(query) self.check_resp_succeeded(resp) - columns = ["udf_is_in(1,0,1,2)", "123"] + columns = ["(1 IN [0,1,2])", "123"] self.check_column_names(resp, columns) expect_result = [[True, 123]] self.check_result(resp, expect_result) diff --git a/tests/query/v2/test_get_subgraph.py b/tests/query/v2/test_get_subgraph.py index 20bda8328c4..15363a28cda 100644 --- a/tests/query/v2/test_get_subgraph.py +++ b/tests/query/v2/test_get_subgraph.py @@ -5,18 +5,16 @@ # This source code is licensed under Apache 2.0 License, # attached with Common Clause Condition 1.0, found in the LICENSES directory. -from tests.common.nebula_test_suite import NebulaTestSuite -from tests.common.nebula_test_suite import T_NULL, T_EMPTY import pytest +from tests.common.nebula_test_suite import NebulaTestSuite + + +@pytest.mark.usefixtures('set_vertices_and_edges') class TestSubGraph(NebulaTestSuite): @classmethod def prepare(cls): cls.use_nba() - cls.load_vertex_edge() - - def cleanup(): - pass def test_invalid_input(self): stmt = 'GET SUBGRAPH FROM $-.id' @@ -49,7 +47,6 @@ def test_invalid_input(self): def test_zero_step(self): VERTEXS = self.VERTEXS - EDGES = self.EDGES stmt = 'GET SUBGRAPH 0 STEPS FROM "Tim Duncan"' resp = self.execute_query(stmt) @@ -59,8 +56,8 @@ def test_zero_step(self): ] expected_data = { - "column_names" : ['_vertices'], - "rows" : [ + "column_names": ['_vertices'], + "rows": [ [vertices] ] } @@ -75,8 +72,8 @@ def test_zero_step(self): VERTEXS['Spurs'], ] expected_data = { - "column_names" : ['_vertices'], - "rows" : [ + "column_names": ['_vertices'], + "rows": [ [vertices] ] } @@ -92,8 +89,8 @@ def test_zero_step(self): VERTEXS['Tim Duncan'], ] expected_data = { - "column_names" : ['_vertices'], - "rows" : [ + "column_names": ['_vertices'], + "rows": [ [vertices] ] } @@ -108,8 +105,8 @@ def test_zero_step(self): ] expected_data = { - "column_names" : ['_vertices'], - "rows" : [ + "column_names": ['_vertices'], + "rows": [ [vertices] ] } @@ -125,8 +122,8 @@ def test_zero_step(self): ] expected_data = { - "column_names" : ['_vertices'], - "rows" : [ + "column_names": ['_vertices'], + "rows": [ [vertices] ] } @@ -142,8 +139,8 @@ def test_zero_step(self): ] expected_data = { - "column_names" : ['_vertices'], - "rows" : [ + "column_names": ['_vertices'], + "rows": [ [vertices] ] } @@ -160,8 +157,8 @@ def test_zero_step(self): ] expected_data = { - "column_names" : ['_vertices'], - "rows" : [ + "column_names": ['_vertices'], + "rows": [ [vertices] ] } @@ -169,8 +166,7 @@ def test_zero_step(self): self.check_subgraph_result(resp, expected_data["rows"]) def test_subgraph(self): - VERTEXS = self.VERTEXS - EDGES = self.EDGES + VERTEXS, EDGES = self.VERTEXS, self.EDGES stmt = "GET SUBGRAPH FROM 'Tim Duncan'" resp = self.execute_query(stmt) @@ -243,8 +239,8 @@ def test_subgraph(self): ] expected_data = { - "column_names" : ["_vertices", "_edges"], - "rows" : [ + "column_names": ["_vertices", "_edges"], + "rows": [ [vertex1, edge1], [vertex2, edge2] ] @@ -280,7 +276,6 @@ def test_subgraph(self): EDGES['Tim Duncan'+'Tony Parker'+'teammate'+'0'] ] - vertex2 = [ VERTEXS['Danny Green'], VERTEXS['Manu Ginobili'], @@ -445,8 +440,8 @@ def test_subgraph(self): ] expected_data = { - "column_names" : ["_vertices", "_edges"], - "rows" : [ + "column_names": ["_vertices", "_edges"], + "rows": [ [vertex1, edge1], [vertex2, edge2], [vertex3, edge3] @@ -525,8 +520,8 @@ def test_subgraph(self): ] expected_data = { - "column_names" : ["_vertices", "_edges"], - "rows" : [ + "column_names": ["_vertices", "_edges"], + "rows": [ [vertex1, edge1], [vertex2, edge2], [vertex3, edge3] @@ -678,8 +673,8 @@ def test_subgraph(self): ] expected_data = { - "column_names" : ["_vertices", "_edges"], - "rows" : [ + "column_names": ["_vertices", "_edges"], + "rows": [ [vertex1, edge1], [vertex2, edge2], [vertex3, edge3] @@ -733,8 +728,8 @@ def test_subgraph(self): ] expected_data = { - "column_names" : ["_vertices", "_edges"], - "rows" : [ + "column_names": ["_vertices", "_edges"], + "rows": [ [vertex1, edge1], [vertex2, edge2], [vertex3, edge3] @@ -837,8 +832,8 @@ def test_subgraph(self): ] expected_data = { - "column_names" : ["_vertices", "_edges"], - "rows" : [ + "column_names": ["_vertices", "_edges"], + "rows": [ [vertex1, edge1], [vertex2, edge2], [vertex3, edge3], @@ -895,8 +890,8 @@ def test_subgraph(self): ] expected_data = { - "column_names" : ["_vertices", "_edges"], - "rows" : [ + "column_names": ["_vertices", "_edges"], + "rows": [ [vertex1, edge1], [vertex2, edge2] ] @@ -975,8 +970,8 @@ def test_subgraph(self): ] expected_data = { - "column_names" : ["_vertices", "_edges"], - "rows" : [ + "column_names": ["_vertices", "_edges"], + "rows": [ [vertex1, edge1], [vertex2, edge2] ] @@ -1057,8 +1052,8 @@ def test_subgraph(self): ] expected_data = { - "column_names" : ["_vertices", "_edges"], - "rows" : [ + "column_names": ["_vertices", "_edges"], + "rows": [ [vertex1, edge1], [vertex2, edge2] ]