Exemplo n.º 1
0
	def test_hook_index_inclusions(self):
		file = StringIO('{bob}<=|index1| {"foo":"bar"}')
		batch = geoff.Loader(self.graph_db).compile(file, bob=self.graph_db.get_reference_node())
		# Currently only works for v1.5+
		self.assertEqual(
			'[{"method":"POST","to":"/index/node/index1","body":{"uri":"/node/0","key":"foo","value":"bar"},"id":0}]',
			repr(batch)
		)
Exemplo n.º 2
0
	def test_node_index_inclusions(self):
		file = StringIO("""\
(bob)
(bob)<=|index1| {"foo":"bar"}
""")
		batch = geoff.Loader(self.graph_db).compile(file)
		# Currently only works for v1.5+
		self.assertEqual(
			'[' +
			'{"method":"POST","to":"/node","body":null,"id":0},' +
			'{"method":"POST","to":"/index/node/index1","body":{"uri":"{0}","key":"foo","value":"bar"},"id":1}' +
			']',
			repr(batch)
		)
Exemplo n.º 3
0
	def test_relationship_index_inclusions(self):
		file = StringIO("""\
(alice)
(bob)
(alice)-[rel:KNOWS]->(bob)
[rel]<=|index1| {"foo":"bar"}
""")
		batch = geoff.Loader(self.graph_db).compile(file)
		# Currently only works for v1.5+
		self.assertEqual(
			'[' +
				'{"method":"POST","to":"/node","body":null,"id":0},' +
				'{"method":"POST","to":"/node","body":null,"id":1},' +
				'{"method":"POST","to":"{0}/relationships","body":{"type":"KNOWS","to":"{1}","data":null},"id":2},' +
				'{"method":"POST","to":"/index/relationship/index1","body":{"uri":"{2}","key":"foo","value":"bar"},"id":3}' +
			']',
			repr(batch)
		)
Exemplo n.º 4
0
	def test_node_descriptors_with_data(self):
		file = StringIO('(foo) {"pi":3.1415}')
		batch = geoff.Loader(self.graph_db).compile(file)
		self.assertEqual('[{"method":"POST","to":"/node","body":{"pi":3.1415},"id":0}]', repr(batch))
Exemplo n.º 5
0
	def test_node_descriptors(self):
		file = StringIO('(foo)')
		batch = geoff.Loader(self.graph_db).compile(file)
		self.assertEqual('[{"method":"POST","to":"/node","body":null,"id":0}]', repr(batch))
Exemplo n.º 6
0
	def test_hook_descriptors_with_data(self):
		file = StringIO('{foo} {"pi":3.1415}')
		batch = geoff.Loader(self.graph_db).compile(file, foo=self.graph_db.get_reference_node())
		self.assertEqual('[{"method":"PUT","to":"/node/0/properties","body":{"pi":3.1415},"id":0}]', repr(batch))
Exemplo n.º 7
0
	def test_comments(self):
		file = StringIO('# this is a comment')
		batch = geoff.Loader(self.graph_db).compile(file)
		self.assertEqual('[]', repr(batch))
Exemplo n.º 8
0
	def test_lines_of_whitespace(self):
		file = StringIO('\t    ')
		batch = geoff.Loader(self.graph_db).compile(file)
		self.assertEqual('[]', repr(batch))
Exemplo n.º 9
0
	def test_blank_lines(self):
		file = StringIO('\n')
		batch = geoff.Loader(self.graph_db).compile(file)
		self.assertEqual('[]', repr(batch))