From fc24172ad406cd53065b869164d2c159751ff00d Mon Sep 17 00:00:00 2001 From: rahul21-7 Date: Tue, 18 Aug 2026 23:46:23 +0530 Subject: [PATCH 1/2] made changes to the test --- tests/test_graphar.py | 53 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 42 insertions(+), 11 deletions(-) diff --git a/tests/test_graphar.py b/tests/test_graphar.py index 908dd78..d52f261 100644 --- a/tests/test_graphar.py +++ b/tests/test_graphar.py @@ -1,18 +1,49 @@ import yaml from icebug_format.graphar import YamlGraphInfo -def test_yaml_parser_fallback_loads_empty_graph(tmp_path): - """Test that our fallback YAML parser can read a basic graph configuration.""" - yaml_content = { - "vertices": [], - "edges": [] +def test_yaml_parser_fallback_loads_simple_graph(tmp_path): + """Test that the custom YAML parser correctly reads a multi-file graph configuration.""" + + # 1. Create a dummy vertex YAML file + vertex_content = {"type": "person", "prefix": "vertex/person/"} + vertex_file = tmp_path / "person.vertex.yml" + with open(vertex_file, "w") as f: + yaml.dump(vertex_content, f) + + # 2. Create a dummy edge YAML file + edge_content = { + "src_type": "person", + "edge_type": "knows", + "dst_type": "person", + "prefix": "edge/person_knows_person/" + } + edge_file = tmp_path / "person_knows_person.edge.yml" + with open(edge_file, "w") as f: + yaml.dump(edge_content, f) + + # 3. Create the main graph YAML file that links to the other two + graph_content = { + "name": "simple_graph", + "vertices": ["person.vertex.yml"], + "edges": ["person_knows_person.edge.yml"] } - yaml_file = tmp_path / "test.graph.yml" + graph_file = tmp_path / "test.graph.yml" + with open(graph_file, "w") as f: + yaml.dump(graph_content, f) - with open(yaml_file, "w") as f: - yaml.dump(yaml_content, f) + # 4. Load it using your custom parser! + graph_info = YamlGraphInfo.load(str(graph_file)) - graph_info = YamlGraphInfo.load(str(yaml_file)) + # 5. Verify the vertex data matches exactly + assert graph_info.vertex_info_num() == 1 + v_info = graph_info.get_vertex_info_by_index(0) + assert v_info.get_type() == "person" + assert v_info.get_prefix() == "vertex/person/" - assert graph_info.vertex_info_num() == 0 - assert graph_info.edge_info_num() == 0 \ No newline at end of file + # 6. Verify the edge data matches exactly + assert graph_info.edge_info_num() == 1 + e_info = graph_info.get_edge_info_by_index(0) + assert e_info.get_edge_type() == "knows" + assert e_info.get_src_type() == "person" + assert e_info.get_dst_type() == "person" + assert e_info.get_prefix() == "edge/person_knows_person/" \ No newline at end of file From e80c0d6c9b04b3acfbb76e58c7d3855d51234e18 Mon Sep 17 00:00:00 2001 From: rahul21-7 Date: Wed, 19 Aug 2026 22:04:23 +0530 Subject: [PATCH 2/2] test: pad mock YAML files with strict GraphAr schema requirements --- tests/test_graphar.py | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/tests/test_graphar.py b/tests/test_graphar.py index d52f261..71bcce1 100644 --- a/tests/test_graphar.py +++ b/tests/test_graphar.py @@ -4,26 +4,50 @@ def test_yaml_parser_fallback_loads_simple_graph(tmp_path): """Test that the custom YAML parser correctly reads a multi-file graph configuration.""" - # 1. Create a dummy vertex YAML file - vertex_content = {"type": "person", "prefix": "vertex/person/"} + # 1. Create a fully compliant vertex YAML file + vertex_content = { + "type": "person", + "prefix": "vertex/person/", + "chunk_size": 100, + "version": "gar/v1", + "property_groups": [ + { + "file_type": "parquet", + "properties": [ + {"name": "id", "data_type": "int64", "is_primary": True} + ] + } + ] + } vertex_file = tmp_path / "person.vertex.yml" with open(vertex_file, "w") as f: yaml.dump(vertex_content, f) - # 2. Create a dummy edge YAML file + # 2. Create a fully compliant edge YAML file edge_content = { "src_type": "person", "edge_type": "knows", "dst_type": "person", - "prefix": "edge/person_knows_person/" + "prefix": "edge/person_knows_person/", + "chunk_size": 1024, + "version": "gar/v1", + "directed": True, + "adj_lists": [ + { + "ordered": False, + "aligned_by": "src", + "file_type": "parquet" + } + ] } edge_file = tmp_path / "person_knows_person.edge.yml" with open(edge_file, "w") as f: yaml.dump(edge_content, f) - # 3. Create the main graph YAML file that links to the other two + # 3. Create the main graph YAML file graph_content = { "name": "simple_graph", + "version": "gar/v1", "vertices": ["person.vertex.yml"], "edges": ["person_knows_person.edge.yml"] } @@ -31,7 +55,7 @@ def test_yaml_parser_fallback_loads_simple_graph(tmp_path): with open(graph_file, "w") as f: yaml.dump(graph_content, f) - # 4. Load it using your custom parser! + # 4. Load it using your custom parser graph_info = YamlGraphInfo.load(str(graph_file)) # 5. Verify the vertex data matches exactly