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))
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))
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)
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
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
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
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