def debug_create_people(graph): people = [] relations = [] for x in range(10): p = Person() p.name = "Alice %d" % x people.append(p) if len(people) > 0: r = Relationship(Graph.cast(p), "KNOWS", Graph.cast(people[-1])) relations.append(r) print(graph.create(people)) print(graph.create(relations))
def test_can_cast_3_tuple(): casted = Graph.cast(("Alice", "KNOWS", "Bob")) assert isinstance(casted, Relationship) assert not casted.bound assert casted.start_node == Node("Alice") assert casted.type == "KNOWS" assert casted.end_node == Node("Bob")
def test_can_cast_rel(graph): a, b, ab = graph.create({}, {}, (0, "KNOWS", 1)) casted = Graph.cast(ab) assert isinstance(casted, Relationship) assert casted.bound assert casted.start_node == a assert casted.type == "KNOWS" assert casted.end_node == b
def test_can_cast_dict(): casted = Graph.cast({"name": "Alice"}) assert isinstance(casted, Node) assert not casted.bound assert casted["name"] == "Alice"
def test_can_cast_node(graph): alice, = graph.create({"name": "Alice"}) casted = Graph.cast(alice) assert isinstance(casted, Node) assert casted.bound assert casted["name"] == "Alice"