def test(self): s = Serializer() n = Node({'foo': 'bar', 'bar': 1}) # Add properties for coverage n.labels = ['Special'] n.match_props = ['foo'] n.update_props = ['bar'] rels = n.relate([Node() for _ in range(5)], 'NEXT') o = Node() n.relate(o, 'OTHER') # Add properties for coverage rels[0].match_props = ['foo'] rels[0].update_props = ['bar'] # Single relationship (and start and end node) s.serialize(rels[0]) # Remaining rels s.serialize(rels[1:]) s.serialize(n) # No effect s.serialize(n, traverse=False) s.serialize(rels[0]) self.assertRaises(TypeError, s.serialize, None) self.assertEqual(len(s.items), 13) self.assertEqual(len(s.batches), 2)
def test_parse_create_node(self): n = Node({'foo': None}) s = 'CREATE (x0)' self.assertEqual(neo4j.parse(serialize(n))[0], s) n['foo'] = 1 n['bar'] = 'a' s = "CREATE (x0 {bar: 'a', foo: 1})" self.assertEqual(neo4j.parse(serialize(n))[0], s) n.labels = ['Special'] s = "CREATE (x0:Special {bar: 'a', foo: 1})" self.assertEqual(neo4j.parse(serialize(n))[0], s)
def setUp(self): n = Node({'foo': 'bar', 'baz': 10}) # Add properties for coverage n.labels = ['Special'] n.match_props = ['foo'] n.update_props = ['baz'] rels = [] for i in range(5): rels.append(n.relate(Node({'index': i}), 'NEXT', {'foo': i, 'bar': 2})) rels[0].match_props = ['foo'] rels[0].update_props = ['bar'] self.data = serialize(n)
def setUp(self): n = Node({'foo': 'bar', 'baz': 10}) # Add properties for coverage n.labels = ['Special'] n.match_props = ['foo'] n.update_props = ['baz'] rels = [] for i in range(5): rels.append( n.relate(Node({'index': i}), 'NEXT', { 'foo': i, 'bar': 2 })) rels[0].match_props = ['foo'] rels[0].update_props = ['bar'] self.data = serialize(n)