def test_edge_change_anchor_valuerror(db_3_vertices): """Test if the change_anchor method raises an exception. When the given anchor doesn't belong the the edge. """ db, v1, v2, v3 = db_3_vertices e1 = Edge(v1, v2) with pytest.raises(ValueError): e1.change_anchor(v3)
def test_edge_change_anchor(db_3_vertices): """Test if the change_anchor method changes the right attributes.""" db, v1, v2, v3 = db_3_vertices e1 = Edge(v1, v2) e1.change_anchor(v1) assert e1.anchor is v1 assert e1.other is v2 assert e1.direction == "out" e1.change_anchor(v2) assert e1.anchor is v2 assert e1.other is v1 assert e1.direction == "in" e2 = Edge(v2, v3, has_direction=False) e2.change_anchor(v2) assert e2.anchor is v2 assert e2.other is v3 assert e2.direction == "none" e2.change_anchor(v3) assert e2.anchor is v3 assert e2.other is v2 assert e2.direction == "none"