33import yaml
44
55from pathlib import Path
6- from gqlalchemy import Memgraph , Node
6+ from gqlalchemy import Memgraph , Node , Path as path_gql
77from mgclient import Node as node_mgclient
8+ from mgclient import Relationship as relationship_mgclient
89
910
1011@pytest .fixture
@@ -35,6 +36,25 @@ def _node_to_dict(data):
3536 return {"labels" : list (labels ), "properties" : properties }
3637
3738
39+ def _relationship_to_dict (data ):
40+ label = data .type if hasattr (data , "label" ) else data ._type
41+ properties = data .properties if hasattr (data , "properties" ) else data ._properties
42+ return {"label" : label , "properties" : properties }
43+
44+
45+ def _path_to_dict (data ):
46+ nodes = data .nodes if hasattr (data , "nodes" ) else data ._nodes
47+ relationships = (
48+ data .relationships if hasattr (data , "relationships" ) else data ._relationships
49+ )
50+ return {
51+ "nodes" : [_node_to_dict (node ) for node in nodes ],
52+ "relationships" : [
53+ _relationship_to_dict (relationship ) for relationship in relationships
54+ ],
55+ }
56+
57+
3858def _replace (data , match_classes ):
3959 if isinstance (data , dict ):
4060 return {k : _replace (v , match_classes ) for k , v in data .items ()}
@@ -44,6 +64,10 @@ def _replace(data, match_classes):
4464 return pytest .approx (data , abs = TestConstants .ABSOLUTE_TOLERANCE )
4565 elif isinstance (data , node_mgclient ):
4666 return _node_to_dict (data )
67+ elif isinstance (data , relationship_mgclient ):
68+ return _relationship_to_dict (data )
69+ elif isinstance (data , path_gql ):
70+ return _path_to_dict (data )
4771 else :
4872 return _node_to_dict (data ) if isinstance (data , match_classes ) else data
4973
0 commit comments