Exemple #1
0
 def test_can_parse_longer_path(self):
     nodes, rels, entries = parse('(A)-[:KNOWS]->'
                                  '(B)-[:KNOWS]->'
                                  '(C)<-[:KNOWS]-'
                                  '(D)')
     assert nodes == {
         "A": geoff.AbstractNode("A", {}),
         "B": geoff.AbstractNode("B", {}),
         "C": geoff.AbstractNode("C", {}),
         "D": geoff.AbstractNode("D", {}),
     }
     assert rels == [
         geoff.AbstractRelationship(nodes["A"], "KNOWS", {}, nodes["B"]),
         geoff.AbstractRelationship(nodes["B"], "KNOWS", {}, nodes["C"]),
         geoff.AbstractRelationship(nodes["D"], "KNOWS", {}, nodes["C"]),
     ]
     assert entries == {}
Exemple #2
0
 def test_can_parse_relationship(self):
     nodes, rels, entries = parse('(A)-[:KNOWS]->(B) {"since": 1999}')
     assert nodes == {
         "A": geoff.AbstractNode("A", {}),
         "B": geoff.AbstractNode("B", {}),
     }
     assert rels == [
         geoff.AbstractRelationship(nodes["A"], "KNOWS", {"since": 1999}, nodes["B"]),
     ]
     assert entries == {}
Exemple #3
0
 def test_can_parse_longer_path_and_data(self):
     nodes, rels, entries = parse(
         '(A {"name":"Alice","age":34})-[:KNOWS {since:1999}]->'
         '(B {"name":"Bob"})-[:KNOWS {friends:true}]->'
         '(C {"name":"Carol"})<-[:KNOWS]-'
         '(D {"name":"Dave"})'
     )
     assert nodes == {
         "A": geoff.AbstractNode("A", {"name": "Alice", "age": 34}),
         "B": geoff.AbstractNode("B", {"name": "Bob"}),
         "C": geoff.AbstractNode("C", {"name": "Carol"}),
         "D": geoff.AbstractNode("D", {"name": "Dave"}),
     }
     assert rels == [
         geoff.AbstractRelationship(nodes["A"], "KNOWS", {"since": 1999}, nodes["B"]),
         geoff.AbstractRelationship(nodes["B"], "KNOWS", {"friends": True}, nodes["C"]),
         geoff.AbstractRelationship(nodes["D"], "KNOWS", {}, nodes["C"]),
     ]
     assert entries == {}