Beispiel #1
0
 def test_construction_of_path_length_2(self):
     sequence = [alice, alice_knows_bob, bob, carol_dislikes_bob, carol]
     path = Path(*sequence)
     assert repr(path)
     assert path.order() == 3
     assert path.size() == 2
     assert path.length() == 2
     assert set(path.nodes()) == {alice, bob, carol}
     assert set(path.relationships()) == {alice_knows_bob, carol_dislikes_bob}
     assert path.start_node() == alice
     assert path.end_node() == carol
     assert path.length() == 2
     assert list(path.traverse()) == sequence
Beispiel #2
0
 def test_construction_of_path_with_loop(self):
     sequence = [carol, carol_married_to_dave, dave, dave_works_for_dave, dave]
     path = Path(*sequence)
     assert repr(path)
     assert path.order() == 2
     assert path.size() == 2
     assert path.length() == 2
     assert set(path.nodes()) == {carol, dave}
     assert set(path.relationships()) == {carol_married_to_dave, dave_works_for_dave}
     assert path.start_node() == carol
     assert path.end_node() == dave
     assert path.length() == 2
     assert list(path.traverse()) == sequence
Beispiel #3
0
 def test_construction_of_path_length_0(self):
     sequence = [alice]
     path = Path(*sequence)
     assert repr(path)
     assert path.order() == 1
     assert path.size() == 0
     assert path.length() == 0
     assert set(path.nodes()) == {alice}
     assert set(path.relationships()) == set()
     assert path.start_node() == alice
     assert path.end_node() == alice
     assert path.length() == 0
     assert list(path.traverse()) == sequence
Beispiel #4
0
 def test_construction_of_path_length_1(self):
     sequence = [alice, alice_knows_bob, bob]
     path = Path(*sequence)
     assert repr(path)
     assert path.order() == 2
     assert path.size() == 1
     assert path.length() == 1
     assert set(path.nodes()) == {alice, bob}
     assert set(path.relationships()) == {alice_knows_bob}
     assert path.start_node() == alice
     assert path.end_node() == bob
     assert path.length() == 1
     assert list(path.traverse()) == sequence
Beispiel #5
0
 def test_construction_of_path_length_0(self):
     sequence = [alice]
     path = Path(*sequence)
     assert repr(path)
     assert path.order() == 1
     assert path.size() == 0
     assert path.length() == 0
     assert set(path.nodes()) == {alice}
     assert set(path.relationships()) == set()
     assert path.start_node() == alice
     assert path.end_node() == alice
     assert path.length() == 0
     assert list(path.traverse()) == sequence
Beispiel #6
0
 def test_construction_of_path_with_loop(self):
     sequence = [
         carol, carol_married_to_dave, dave, dave_works_for_dave, dave
     ]
     path = Path(*sequence)
     assert repr(path)
     assert path.order() == 2
     assert path.size() == 2
     assert path.length() == 2
     assert set(path.nodes()) == {carol, dave}
     assert set(path.relationships()) == {
         carol_married_to_dave, dave_works_for_dave
     }
     assert path.start_node() == carol
     assert path.end_node() == dave
     assert path.length() == 2
     assert list(path.traverse()) == sequence
Beispiel #7
0
 def test_construction_of_path_with_revisits(self):
     sequence = [
         alice, alice_knows_bob, bob, carol_dislikes_bob, carol,
         alice_likes_carol, alice, alice_knows_bob, bob
     ]
     path = Path(*sequence)
     assert repr(path)
     assert path.order() == 3
     assert path.size() == 3
     assert path.length() == 4
     assert set(path.nodes()) == {alice, bob, carol}
     assert set(path.relationships()) == {
         alice_knows_bob, alice_likes_carol, carol_dislikes_bob
     }
     assert path.start_node() == alice
     assert path.end_node() == bob
     assert path.length() == 4
     assert list(path.traverse()) == sequence