Exemplo n.º 1
0
def create(count):

    t = [time()]

    batch = Batch(graph)
    for i in range(count):
        batch.create_node(properties={"number": i, "uuid": uuid4().hex})

    t.append(time())

    nodes = list(batch.submit())

    t.append(time())

    rel_types = [
        "RED", "ORANGE", "YELLOW", "GREEN", "BLUE", "INDIGO", "VIOLET"
    ]
    batch = Batch(graph)
    for i in range(count):
        batch.create_rel(start=random.choice(nodes)._id,
                         end=random.choice(nodes)._id,
                         type=random.choice(rel_types))

    t.append(time())

    rels = list(batch.submit())

    t.append(time())

    print("")
    #print("Creation   : {:.3f}s/1000".format(1000 * (t[1] - t[0]) / count))
    print("Nodes : {:.3f}s/1000".format(1000 * (t[2] - t[1]) / count))
    print("Rels  : {:.3f}s/1000".format(1000 * (t[4] - t[3]) / count))
Exemplo n.º 2
0
def create(count):

    t = [time()]

    batch = Batch(graph)
    for i in range(count):
        batch.create_node(properties={"number": i, "uuid": uuid4().hex})

    t.append(time())

    nodes = list(batch.submit())

    t.append(time())

    rel_types = ["RED", "ORANGE", "YELLOW", "GREEN", "BLUE", "INDIGO", "VIOLET"]
    batch = Batch(graph)
    for i in range(count):
        batch.create_rel(start=random.choice(nodes)._id, end=random.choice(nodes)._id, type=random.choice(rel_types))

    t.append(time())

    rels = list(batch.submit())

    t.append(time())

    print("")
    # print("Creation   : {:.3f}s/1000".format(1000 * (t[1] - t[0]) / count))
    print("Nodes : {:.3f}s/1000".format(1000 * (t[2] - t[1]) / count))
    print("Rels  : {:.3f}s/1000".format(1000 * (t[4] - t[3]) / count))
Exemplo n.º 3
0
 def test_node_does_not_exist(self):
     batch = Batch(self.graph)
     batch.create_node()
     batch.delete_node(Pointer(0))
     result = batch.submit()
     node = next(result)
     assert not node.exists
Exemplo n.º 4
0
 def test_node_does_not_exist(self):
     batch = Batch(self.graph)
     batch.create_node()
     batch.delete_node(Pointer(0))
     result = batch.submit()
     node = next(result)
     assert not node.exists
Exemplo n.º 5
0
 def test_can_use_pointers(self):
     batch = Batch(self.graph)
     a = batch.create_node()
     b = batch.create_node()
     batch.create_rel(a, b, "KNOWS")
     results = batch.submit()
     for result in results:
         print(result)
Exemplo n.º 6
0
 def test_remote_node_changes_can_be_pulled(self):
     batch = Batch(self.graph)
     batch.create_node({"Person"}, {"name": "Alice"})
     result = batch.submit()
     remote = next(result)
     local = Node()
     local.bind(self.graph, id=remote._id)
     local.pull()
     assert local.labels == remote.labels
     assert local.properties == remote.properties
Exemplo n.º 7
0
 def test_remote_node_changes_can_be_pulled(self):
     batch = Batch(self.graph)
     batch.create_node({"Person"}, {"name": "Alice"})
     result = batch.submit()
     remote = next(result)
     local = Node()
     local.bind(self.graph, id=remote._id)
     local.pull()
     assert local.labels == remote.labels
     assert local.properties == remote.properties
Exemplo n.º 8
0
 def test_local_node_changes_can_be_pushed(self):
     batch = Batch(self.graph)
     batch.create_node()
     result = batch.submit()
     remote = next(result)
     local = Node("Person", name="Alice")
     local.bind(self.graph, id=remote._id)
     local.push()
     remote = Batch.single(self.graph, Batch.get_node, local._id)
     assert remote.labels == local.labels
     assert remote.properties == local.properties
Exemplo n.º 9
0
 def test_local_node_changes_can_be_pushed(self):
     batch = Batch(self.graph)
     batch.create_node()
     result = batch.submit()
     remote = next(result)
     local = Node("Person", name="Alice")
     local.bind(self.graph, id=remote._id)
     local.push()
     remote = Batch.single(self.graph, Batch.get_node, local._id)
     assert remote.labels == local.labels
     assert remote.properties == local.properties
Exemplo n.º 10
0
 def test_rel_exists(self):
     batch = Batch(self.graph)
     a = batch.create_node()
     b = batch.create_node()
     ab = batch.create_rel(a, b, "KNOWS")
     result = batch.submit()
     alice = next(result)
     bob = next(result)
     alice_bob = next(result)
     alice_bob_rel = alice_bob.rels[0]
     assert alice_bob_rel.exists
Exemplo n.º 11
0
 def test_rel_exists(self):
     batch = Batch(self.graph)
     a = batch.create_node()
     b = batch.create_node()
     ab = batch.create_rel(a, b, "KNOWS")
     result = batch.submit()
     alice = next(result)
     bob = next(result)
     alice_bob = next(result)
     alice_bob_rel = alice_bob.rels[0]
     assert alice_bob_rel.exists
Exemplo n.º 12
0
 def test_node_does_not_exist(self):
     batch = Batch(self.graph)
     a = batch.create_node()
     b = batch.create_node()
     ab = batch.create_rel(a, b, "KNOWS")
     result = batch.submit()
     alice = next(result)
     bob = next(result)
     alice_bob = next(result)
     alice_bob_rel = alice_bob.rels[0]
     Batch.single(self.graph, Batch.delete_rel, alice_bob_rel._id)
     assert not alice_bob_rel.exists
Exemplo n.º 13
0
 def test_node_does_not_exist(self):
     batch = Batch(self.graph)
     a = batch.create_node()
     b = batch.create_node()
     ab = batch.create_rel(a, b, "KNOWS")
     result = batch.submit()
     alice = next(result)
     bob = next(result)
     alice_bob = next(result)
     alice_bob_rel = alice_bob.rels[0]
     Batch.single(self.graph, Batch.delete_rel, alice_bob_rel._id)
     assert not alice_bob_rel.exists
Exemplo n.º 14
0
 def test_remote_rel_changes_can_be_pulled(self):
     batch = Batch(self.graph)
     a = batch.create_node()
     b = batch.create_node()
     ab = batch.create_rel(a, b, "KNOWS")
     result = batch.submit()
     alice = next(result)
     bob = next(result)
     alice_bob = next(result)
     local = Rel("KNOWS")
     local.bind(self.graph, id=alice_bob._id)
     local.pull()
     assert local.type == alice_bob.type
     assert local.properties == alice_bob.properties
Exemplo n.º 15
0
 def test_remote_rel_changes_can_be_pulled(self):
     batch = Batch(self.graph)
     a = batch.create_node()
     b = batch.create_node()
     ab = batch.create_rel(a, b, "KNOWS")
     result = batch.submit()
     alice = next(result)
     bob = next(result)
     alice_bob = next(result)
     local = Rel("KNOWS")
     local.bind(self.graph, id=alice_bob._id)
     local.pull()
     assert local.type == alice_bob.type
     assert local.properties == alice_bob.properties
Exemplo n.º 16
0
 def test_local_rel_changes_can_be_pushed(self):
     batch = Batch(self.graph)
     a = batch.create_node()
     b = batch.create_node()
     ab = batch.create_rel(a, b, "KNOWS")
     result = batch.submit()
     alice = next(result)
     bob = next(result)
     alice_bob = next(result)
     local = Rel("KNOWS", since=1999)
     local.bind(self.graph, id=alice_bob._id)
     local.push()
     remote = Batch.single(self.graph, Batch.get_rel, local._id)
     assert remote.type == local.type
     assert remote.properties == local.properties
Exemplo n.º 17
0
 def test_local_rel_changes_can_be_pushed(self):
     batch = Batch(self.graph)
     a = batch.create_node()
     b = batch.create_node()
     ab = batch.create_rel(a, b, "KNOWS")
     result = batch.submit()
     alice = next(result)
     bob = next(result)
     alice_bob = next(result)
     local = Rel("KNOWS", since=1999)
     local.bind(self.graph, id=alice_bob._id)
     local.push()
     remote = Batch.single(self.graph, Batch.get_rel, local._id)
     assert remote.type == local.type
     assert remote.properties == local.properties
Exemplo n.º 18
0
 def test_node_exists(self):
     batch = Batch(self.graph)
     batch.create_node()
     result = batch.submit()
     node = next(result)
     assert node.exists
Exemplo n.º 19
0
 def test_node_exists(self):
     batch = Batch(self.graph)
     batch.create_node()
     result = batch.submit()
     node = next(result)
     assert node.exists