def test_construction_from_more_arguments(self): try: Relationship(alice, "KNOWS", bob, carol) except TypeError: assert True else: assert False
def test_construction_from_three_arguments(self): rel = Relationship(alice, "KNOWS", bob) assert repr(rel) assert rel.start_node() is alice assert rel.end_node() is bob assert rel.type() == "KNOWS"
def test_construction_from_two_arguments(self): rel = Relationship(alice, bob) assert repr(rel) assert rel.start_node() is alice assert rel.end_node() is bob assert rel.type() is None
def test_construction_from_one_argument(self): rel = Relationship("KNOWS") assert repr(rel) assert rel.start_node() is None assert rel.end_node() is None assert rel.type() == "KNOWS"
def test_construction_from_zero_arguments(self): rel = Relationship() assert repr(rel) assert rel.start_node() is None assert rel.end_node() is None assert rel.type() is None
def test_can_concatenate_reversed_relationship_and_reversed_relationship( self): bob_knows_alice = Relationship(bob, "KNOWS", alice) result = bob_knows_alice + carol_dislikes_bob assert result == TraversableGraph(alice, bob_knows_alice, bob, carol_dislikes_bob, carol)
def test_can_concatenate_relationship_and_node(self): bob_knows_alice = Relationship(bob, "KNOWS", alice) result = bob_knows_alice + bob assert result == TraversableGraph(alice, bob_knows_alice, bob)
def test_inequality(self): other_rel = Relationship(alice, "KNOWS", bob, since=1999) assert alice != other_rel
# GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. from unittest import TestCase from cypy.primitive import PropertySet, PropertyContainer, TraversableGraph, \ Graph, Node, Relationship, Path, Record, RecordList alice = Node("Person", "Employee", name="Alice", age=33) bob = Node("Person") carol = Node("Person") dave = Node("Person") alice_knows_bob = Relationship(alice, "KNOWS", bob, since=1999) alice_likes_carol = Relationship(alice, "LIKES", carol) carol_dislikes_bob = Relationship(carol, "DISLIKES", bob) carol_married_to_dave = Relationship(carol, "MARRIED_TO", dave) dave_works_for_dave = Relationship(dave, "WORKS_FOR", dave) record_keys = ["employee_id", "Person"] record_a = Record(record_keys, [1001, alice]) record_b = Record(record_keys, [1002, bob]) record_c = Record(record_keys, [1003, carol]) record_d = Record(record_keys, [1004, dave]) record_list = RecordList([record_a, record_b, record_c, record_d]) class PropertyCoercionTestCase(TestCase):