Beispiel #1
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)
Beispiel #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)
Beispiel #3
0
    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)
Beispiel #4
0
    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)
Beispiel #5
0
    def test_parse_merge_node(self):
        n = Node({'foo': 1, 'bar': 'a', 'baz': None}, labels=['Special'],
                 match_props=['foo'])
        s = "MERGE (x0:Special {foo: 1}) " \
            "ON CREATE SET x0 = {bar: 'a', foo: 1} " \
            "ON MATCH SET x0.bar = 'a', x0.foo = 1"
        self.assertEqual(neo4j.parse(serialize(n))[0], s)

        # Replace properties on match
        d = serialize(n)
        d[0]['replace'] = True
        s = "MERGE (x0:Special {foo: 1}) " \
            "ON CREATE SET x0 = {bar: 'a', foo: 1} " \
            "ON MATCH SET x0 = {bar: 'a', foo: 1}"
        self.assertEqual(neo4j.parse(d)[0], s)
Beispiel #6
0
 def test_parse_merge_rel(self):
     n = Node()
     r = n.relate(Node(), 'TO', {'foo': 1, 'bar': 'a'}, match_props=['foo'])
     s = "MERGE (x0)-[x2:TO {foo: 1}]->(x1) " \
         "ON CREATE SET x2 = {bar: 'a', foo: 1} " \
         "ON MATCH SET x2.bar = 'a', x2.foo = 1"
     # Third statement.. after creating the nodes
     self.assertEqual(neo4j.parse(serialize(r))[2], s)
Beispiel #7
0
 def test_parse_merge_rel(self):
     n = Node()
     r = n.relate(Node(), 'TO', {'foo': 1, 'bar': 'a'}, match_props=['foo'])
     s = "MERGE (x0)-[x2:TO {foo: 1}]->(x1) " \
         "ON CREATE SET x2 = {bar: 'a', foo: 1} " \
         "ON MATCH SET x2.bar = 'a', x2.foo = 1"
     # Third statement.. after creating the nodes
     self.assertEqual(neo4j.parse(serialize(r))[2], s)
Beispiel #8
0
    def test_parse_merge_node(self):
        n = Node({
            'foo': 1,
            'bar': 'a',
            'baz': None
        },
                 labels=['Special'],
                 match_props=['foo'])
        s = "MERGE (x0:Special {foo: 1}) " \
            "ON CREATE SET x0 = {bar: 'a', foo: 1} " \
            "ON MATCH SET x0.bar = 'a', x0.foo = 1"
        self.assertEqual(neo4j.parse(serialize(n))[0], s)

        # Replace properties on match
        d = serialize(n)
        d[0]['replace'] = True
        s = "MERGE (x0:Special {foo: 1}) " \
            "ON CREATE SET x0 = {bar: 'a', foo: 1} " \
            "ON MATCH SET x0 = {bar: 'a', foo: 1}"
        self.assertEqual(neo4j.parse(d)[0], s)
Beispiel #9
0
 def test_parse_dict(self):
     data = convert_array_to_dict(self.data)
     self.assertTrue(neo4j.parse(data))
Beispiel #10
0
 def test_parse(self):
     statements = neo4j.parse(self.data)
     self.assertTrue(statements)
Beispiel #11
0
 def test_parse(self):
     statements = neo4j.parse(self.data)
     self.assertTrue(statements)
Beispiel #12
0
 def test_parse_dict(self):
     data = convert_array_to_dict(self.data)
     self.assertTrue(neo4j.parse(data))