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)
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)
def test_parsing_single_node_with_data(self): rules = geoff._parse('(A) {"name": "Alice"}') self.assertEqual([(geoff.NODE, 'A', {'name': 'Alice'})], rules)
def test_parsing_single_node(self): rules = geoff._parse('(A)') self.assertEqual([(geoff.NODE, 'A', {})], rules)
def test_parsing_comment(self): rules = geoff._parse('# this is a comment') self.assertEqual([], rules)
def test_parsing_blank_lines(self): rules = geoff._parse('\n\n\n') self.assertEqual([], rules)
def test_parsing_empty_string(self): rules = geoff._parse('') self.assertEqual([], rules)