Beispiel #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))
Beispiel #2
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
Beispiel #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
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))
Beispiel #5
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
Beispiel #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
Beispiel #7
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
Beispiel #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
Beispiel #9
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)
Beispiel #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
Beispiel #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
Beispiel #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
Beispiel #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
Beispiel #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
Beispiel #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
Beispiel #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
Beispiel #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
Beispiel #18
0
 def test_node_exists(self):
     batch = Batch(self.graph)
     batch.create_node()
     result = batch.submit()
     node = next(result)
     assert node.exists
Beispiel #19
0
 def test_node_exists(self):
     batch = Batch(self.graph)
     batch.create_node()
     result = batch.submit()
     node = next(result)
     assert node.exists