Пример #1
0
    def test_cannot_cast_relationship_from_generic_object(self):
        class Foo(object):
            pass

        foo = Foo()
        with self.assertRaises(ValueError):
            cast_relationship((Node(), foo, Node()))
Пример #2
0
 def setUp(self):
     self.batch = ManualIndexWriteBatch(self.graph)
     self.alice = cast_node({"name": "Alice", "surname": "Allison"})
     self.bob = cast_node({"name": "Bob", "surname": "Robertson"})
     self.friends = cast_relationship((self.alice, "KNOWS", self.bob, {
         "since": 2000
     }))
     self.graph.create(self.alice | self.bob | self.friends)
Пример #3
0
 def test_can_cast_relationship_with_integer_nodes(self):
     a = Node()
     b = Node()
     nodes = [a, b]
     r = cast_relationship((0, "TO", 1), nodes)
     assert r.start_node() is a
     assert r.end_node() is b
     assert r.type() == "TO"
Пример #4
0
 def test_can_cast_3_tuple(self):
     alice = Node()
     bob = Node()
     casted = cast_relationship((alice, "KNOWS", bob))
     assert isinstance(casted, Relationship)
     assert not remote(casted)
     assert casted.start_node() == alice
     assert casted.type() == "KNOWS"
     assert casted.end_node() == bob
Пример #5
0
 def test_can_cast_from_tuple_of_entities(self):
     a = Node()
     b = Node()
     r = Relationship(a, "TO", b)
     casted = cast_relationship((a, r, b))
     assert isinstance(casted, Relationship)
     assert not remote(casted)
     assert casted.start_node() == a
     assert casted.type() == "TO"
     assert casted.end_node() == b
Пример #6
0
 def test_can_cast_3_tuple_with_unbound_rel(self):
     alice = Node()
     bob = Node()
     casted = cast_relationship((alice, ("KNOWS", {"since": 1999}), bob))
     assert isinstance(casted, Relationship)
     assert not remote(casted)
     assert casted.start_node() == alice
     assert casted.type() == "KNOWS"
     assert casted.end_node() == bob
     assert casted["since"] == 1999
Пример #7
0
 def test_can_cast_relationship(self):
     a = Node()
     b = Node()
     ab = Relationship(a, "KNOWS", b)
     self.graph.create(a | b | ab)
     casted = cast_relationship(ab)
     assert isinstance(casted, Relationship)
     assert remote(casted)
     assert casted.start_node() == a
     assert casted.type() == "KNOWS"
     assert casted.end_node() == b
Пример #8
0
 def test_cannot_cast_6_tuple(self):
     with self.assertRaises(TypeError):
         cast_relationship(("Alice", "KNOWS", "Bob", "foo", "bar", "baz"))
Пример #9
0
 def test_cannot_cast_2_tuple(self):
     with self.assertRaises(TypeError):
         cast_relationship(("Alice", "KNOWS"))
Пример #10
0
 def test_cannot_cast_0_tuple(self):
     with self.assertRaises(TypeError):
         cast_relationship(())