1313
1414import nx_arangodb as nxadb
1515from nx_arangodb .classes .dict .adj import AdjListOuterDict , EdgeAttrDict , EdgeKeyDict
16+ from nx_arangodb .classes .dict .graph import GRAPH_FIELD
1617from nx_arangodb .classes .dict .node import NodeAttrDict , NodeDict
1718
1819from .conftest import create_grid_graph , create_line_graph , db , run_gpu_tests
@@ -1655,9 +1656,9 @@ def test_graph_dict_init_extended(load_karate_graph: Any) -> None:
16551656 G = nxadb .Graph (name = "KarateGraph" , foo = "bar" , bar = {"baz" : True })
16561657 G .graph ["foo" ] = "!!!"
16571658 G .graph ["bar" ]["baz" ] = False
1658- assert db .document (G .graph .graph_id )["networkx" ]["foo" ] == "!!!"
1659- assert db .document (G .graph .graph_id )["networkx" ]["bar" ]["baz" ] is False
1660- assert "baz" not in db .document (G .graph .graph_id )["networkx" ]
1659+ assert db .document (G .graph .graph_id )[GRAPH_FIELD ]["foo" ] == "!!!"
1660+ assert db .document (G .graph .graph_id )[GRAPH_FIELD ]["bar" ]["baz" ] is False
1661+ assert "baz" not in db .document (G .graph .graph_id )[GRAPH_FIELD ]
16611662
16621663
16631664def test_graph_dict_clear_will_not_remove_remote_data (load_karate_graph : Any ) -> None :
@@ -1675,7 +1676,7 @@ def test_graph_dict_clear_will_not_remove_remote_data(load_karate_graph: Any) ->
16751676 except KeyError :
16761677 raise AssertionError ("Not allowed to fail." )
16771678
1678- assert db .document (G .graph .graph_id )["networkx" ]["ant" ] == {"b" : 6 }
1679+ assert db .document (G .graph .graph_id )[GRAPH_FIELD ]["ant" ] == {"b" : 6 }
16791680
16801681
16811682def test_graph_dict_set_item (load_karate_graph : Any ) -> None :
@@ -1697,10 +1698,10 @@ def test_graph_dict_set_item(load_karate_graph: Any) -> None:
16971698 G .graph ["json" ] = value
16981699
16991700 if value is None :
1700- assert "json" not in db .document (G .graph .graph_id )["networkx" ]
1701+ assert "json" not in db .document (G .graph .graph_id )[GRAPH_FIELD ]
17011702 else :
17021703 assert G .graph ["json" ] == value
1703- assert db .document (G .graph .graph_id )["networkx" ]["json" ] == value
1704+ assert db .document (G .graph .graph_id )[GRAPH_FIELD ]["json" ] == value
17041705
17051706
17061707def test_graph_dict_update (load_karate_graph : Any ) -> None :
@@ -1715,7 +1716,7 @@ def test_graph_dict_update(load_karate_graph: Any) -> None:
17151716 assert G .graph .data ["c" ] == G .graph ["c" ] == "d"
17161717
17171718 # remote
1718- adb_doc = db .document (f"_graphs/{ G .name } " )["networkx" ]
1719+ adb_doc = db .document (f"_graphs/{ G .name } " )[GRAPH_FIELD ]
17191720 assert adb_doc ["a" ] == "b"
17201721 assert adb_doc ["c" ] == "d"
17211722
@@ -1727,8 +1728,8 @@ def test_graph_attr_dict_nested_update(load_karate_graph: Any) -> None:
17271728 G .graph ["a" ].update ({"d" : "e" })
17281729 assert G .graph ["a" ]["b" ] == "c"
17291730 assert G .graph ["a" ]["d" ] == "e"
1730- assert db .document (G .graph .graph_id )["networkx" ]["a" ]["b" ] == "c"
1731- assert db .document (G .graph .graph_id )["networkx" ]["a" ]["d" ] == "e"
1731+ assert db .document (G .graph .graph_id )[GRAPH_FIELD ]["a" ]["b" ] == "c"
1732+ assert db .document (G .graph .graph_id )[GRAPH_FIELD ]["a" ]["d" ] == "e"
17321733
17331734
17341735def test_graph_dict_nested_1 (load_karate_graph : Any ) -> None :
@@ -1737,7 +1738,7 @@ def test_graph_dict_nested_1(load_karate_graph: Any) -> None:
17371738
17381739 G .graph ["a" ] = {"b" : icon }
17391740 assert G .graph ["a" ]["b" ] == icon
1740- assert db .document (G .graph .graph_id )["networkx" ]["a" ]["b" ] == icon
1741+ assert db .document (G .graph .graph_id )[GRAPH_FIELD ]["a" ]["b" ] == icon
17411742
17421743
17431744def test_graph_dict_nested_2 (load_karate_graph : Any ) -> None :
@@ -1749,7 +1750,7 @@ def test_graph_dict_nested_2(load_karate_graph: Any) -> None:
17491750
17501751 assert G .graph ["x" ]["y" ]["amount_of_goals" ] == 1337
17511752 assert (
1752- db .document (G .graph .graph_id )["networkx" ]["x" ]["y" ]["amount_of_goals" ] == 1337
1753+ db .document (G .graph .graph_id )[GRAPH_FIELD ]["x" ]["y" ]["amount_of_goals" ] == 1337
17531754 )
17541755
17551756
@@ -1758,10 +1759,10 @@ def test_graph_dict_empty_values(load_karate_graph: Any) -> None:
17581759
17591760 G .graph ["empty" ] = {}
17601761 assert G .graph ["empty" ] == {}
1761- assert db .document (G .graph .graph_id )["networkx" ]["empty" ] == {}
1762+ assert db .document (G .graph .graph_id )[GRAPH_FIELD ]["empty" ] == {}
17621763
17631764 G .graph ["none" ] = None
1764- assert "none" not in db .document (G .graph .graph_id )["networkx" ]
1765+ assert "none" not in db .document (G .graph .graph_id )[GRAPH_FIELD ]
17651766 assert "none" not in G .graph
17661767
17671768
@@ -1774,15 +1775,16 @@ def test_graph_dict_nested_overwrite(load_karate_graph: Any) -> None:
17741775 G .graph ["a" ]["b" ]["football_icon" ] = "ChangedIcon"
17751776 assert G .graph ["a" ]["b" ]["football_icon" ] == "ChangedIcon"
17761777 assert (
1777- db .document (G .graph .graph_id )["networkx" ]["a" ]["b" ]["football_icon" ]
1778+ db .document (G .graph .graph_id )[GRAPH_FIELD ]["a" ]["b" ]["football_icon" ]
17781779 == "ChangedIcon"
17791780 )
17801781
17811782 # Overwrite entire nested dictionary
17821783 G .graph ["a" ] = {"b" : icon2 }
17831784 assert G .graph ["a" ]["b" ]["basketball_icon" ] == "MJ23"
17841785 assert (
1785- db .document (G .graph .graph_id )["networkx" ]["a" ]["b" ]["basketball_icon" ] == "MJ23"
1786+ db .document (G .graph .graph_id )[GRAPH_FIELD ]["a" ]["b" ]["basketball_icon" ]
1787+ == "MJ23"
17861788 )
17871789
17881790
@@ -1794,7 +1796,7 @@ def test_graph_dict_complex_nested(load_karate_graph: Any) -> None:
17941796 G .graph ["complex" ] = complex_structure
17951797 assert G .graph ["complex" ]["level1" ]["level2" ]["level3" ]["key" ] == "value"
17961798 assert (
1797- db .document (G .graph .graph_id )["networkx" ]["complex" ]["level1" ]["level2" ][
1799+ db .document (G .graph .graph_id )[GRAPH_FIELD ]["complex" ]["level1" ]["level2" ][
17981800 "level3"
17991801 ]["key" ]
18001802 == "value"
@@ -1808,12 +1810,12 @@ def test_graph_dict_nested_deletion(load_karate_graph: Any) -> None:
18081810 G .graph ["x" ] = {"y" : icon }
18091811 del G .graph ["x" ]["y" ]["amount_of_goals" ]
18101812 assert "amount_of_goals" not in G .graph ["x" ]["y" ]
1811- assert "amount_of_goals" not in db .document (G .graph .graph_id )["networkx" ]["x" ]["y" ]
1813+ assert "amount_of_goals" not in db .document (G .graph .graph_id )[GRAPH_FIELD ]["x" ]["y" ]
18121814
18131815 # Delete top-level key
18141816 del G .graph ["x" ]
18151817 assert "x" not in G .graph
1816- assert "x" not in db .document (G .graph .graph_id )["networkx" ]
1818+ assert "x" not in db .document (G .graph .graph_id )[GRAPH_FIELD ]
18171819
18181820
18191821def test_readme (load_karate_graph : Any ) -> None :
0 commit comments