コード例 #1
0
ファイル: util.py プロジェクト: jchillerup/ff
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))
コード例 #2
0
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")
コード例 #3
0
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
コード例 #4
0
def test_can_cast_dict():
    casted = Graph.cast({"name": "Alice"})
    assert isinstance(casted, Node)
    assert not casted.bound
    assert casted["name"] == "Alice"
コード例 #5
0
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"