Esempio n. 1
0
 def test_parsing_simple_graph(self):
     rules = geoff._parse(
         '(A) {"name": "Alice"}\n' \
         '(B) {"name": "Bob"}\n' \
         '(A)-[:KNOWS]->(B)\n'
     )
     self.assertEqual([
         (geoff.NODE, 'A', {'name': 'Alice'}),
         (geoff.NODE, 'B', {'name': 'Bob'}),
         (geoff.RELATIONSHIP, None, ('A', 'KNOWS', 'B', {})),
     ], rules)
Esempio n. 2
0
 def test_parsing_graph_with_unknown_rules(self):
     rules = geoff._parse(
         '(A)<=|People| {"name": "Alice"}\n' \
         '(B)<=|People| {"name": "Bob"}\n' \
         '(A) {"name": "Alice Allison"}\n' \
         '(B) {"name": "Bob Robertson"}\n' \
         '(A)-[:KNOWS]->(B)\n'
     )
     self.assertEqual([
         (geoff.UNKNOWN, None, ('(A)<=|People|', {'name': 'Alice'})),
         (geoff.UNKNOWN, None, ('(B)<=|People|', {'name': 'Bob'})),
         (geoff.NODE, 'A', {'name': 'Alice Allison'}),
         (geoff.NODE, 'B', {'name': 'Bob Robertson'}),
         (geoff.RELATIONSHIP, None, ('A', 'KNOWS', 'B', {})),
     ], rules)
Esempio n. 3
0
 def test_parsing_single_node_with_data(self):
     rules = geoff._parse('(A) {"name": "Alice"}')
     self.assertEqual([(geoff.NODE, 'A', {'name': 'Alice'})], rules)
Esempio n. 4
0
 def test_parsing_single_node(self):
     rules = geoff._parse('(A)')
     self.assertEqual([(geoff.NODE, 'A', {})], rules)
Esempio n. 5
0
 def test_parsing_comment(self):
     rules = geoff._parse('# this is a comment')
     self.assertEqual([], rules)
Esempio n. 6
0
 def test_parsing_blank_lines(self):
     rules = geoff._parse('\n\n\n')
     self.assertEqual([], rules)
Esempio n. 7
0
 def test_parsing_empty_string(self):
     rules = geoff._parse('')
     self.assertEqual([], rules)