Пример #1
0
    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)
Пример #2
0
    def test_parse_create_rel(self):
        r = Node().relate(Node(), 'TO')
        s = 'MERGE (x0)-[x2:TO]->(x1)'
        # Third statement.. after creating the nodes
        self.assertEqual(neo4j.parse(serialize(r))[2], s)

        r['foo'] = 1
        r['bar'] = 'a'
        r.match_props = False
        s = "CREATE (x0)-[:TO {bar: 'a', foo: 1}]->(x1)"
        # Third statement.. after creating the nodes
        self.assertEqual(neo4j.parse(serialize(r))[2], s)
Пример #3
0
    def test_parse_create_rel(self):
        r = Node().relate(Node(), 'TO')
        s = 'MERGE (x0)-[x2:TO]->(x1)'
        # Third statement.. after creating the nodes
        self.assertEqual(neo4j.parse(serialize(r))[2], s)

        r['foo'] = 1
        r['bar'] = 'a'
        r.match_props = False
        s = "CREATE (x0)-[:TO {bar: 'a', foo: 1}]->(x1)"
        # Third statement.. after creating the nodes
        self.assertEqual(neo4j.parse(serialize(r))[2], s)
Пример #4
0
    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)
Пример #5
0
    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)