def test_wall_node(): wn = WallNode(vector=Vector(0, 0)) fail_if( str(wn) != f"WallNode {Node.node_counter - 1} - " + f"@ {Vector(0,0)}") wn2 = WallNode(vector=Vector(0, 0)) fail_if(wn != wn) fail_if(wn == wn2)
def test_room(): Room.room_counter = 0 bl = Node(Vector(0, 0)) tl = Node(Vector(0, 1)) br = Node(Vector(1, 0)) tr = Node(Vector(1, 1)) room_node = RoomNode(Vector(0.5, 0.5), RoomType.kitchen) room = Room(name='name', corners=[tl, bl, tr, br], room_node=room_node) fail_if(room != room) fail_if(room.room_count != 0) fail_if(Room.room_counter != 1) fail_if( str(room) != f"Room defined by" + f" [(1.0, 1.0)" + f", (1.0, 0.0)" + f", (0.0, 0.0)" + f", (0.0, 1.0)]" + f" labelled: {RoomType.kitchen}" + f" name: name" + f" | count: 0") try: Room(name='test', corners=[tl, bl, tr, br], room_node=tl) pytest.fail() except ValueError: pass try: Room(name=0, corners=[tl, bl, tr, br], room_node=room_node) pytest.fail() except ValueError: pass
def test_corner_node(): cn = CornerNode(vector=Vector(0, 0)) fail_if( str(cn) != f"CornerNode {Node.node_counter - 1} - " + f"@ {Vector(0,0)}") cn2 = CornerNode(vector=Vector(0, 0)) fail_if(cn != cn) fail_if(cn == cn2)
def test_floor_plan_rooms(): name = 'test' status = FloorPlanStatus.start fp = FloorPlan(name, status) fail_if(fp.name != name) fail_if(fp.status != status) str(fp) bl = CornerNode(Vector(0, 0)) tl = CornerNode(Vector(0, 1)) tr = CornerNode(Vector(1, 1)) br = CornerNode(Vector(1, 0)) room_node = RoomNode(Vector(0.5, 0.5), RoomType.kitchen) room = Room(name='name', corners=[bl, tl, tr, br], room_node=room_node) try: fp.add_room(0) pytest.fail() except ValueError: pass fp.add_room(room) fail_if(fp.rooms != {room.name: room}) fail_if(not fp.remove_room('name')) fp.add_room(room) fail_if(not fp.remove_room(room)) try: fail_if(fp.remove_room(0)) pytest.fail() except ValueError: pass fp.add_room(room) fail_if(fp.rooms['name'] != room) fail_if(not fp.room_exists(room)) fail_if(not fp.room_exists('name')) try: fail_if(fp.room_exists(0)) pytest.fail() except ValueError: pass room_, ret = fp.rooms_exist(['name', room]) fail_if(not ret) fail_if(fp.remove_room('test')) room_, ret = fp.rooms_exist(['ame', room]) fail_if(ret) fail_if(room_ != 'ame') try: fp.rooms_exist('name') pytest.fail() except ValueError: pass try: fp.rooms_exist([0]) pytest.fail() except ValueError: pass
def test_staircase(): bl = Node(Vector(0.0, 0.0)) tl = Node(Vector(0.0, 1.0)) br = Node(Vector(1.0, 0.0)) tr = Node(Vector(1.0, 1.0)) stairs = Staircase([bl, tl, br, tr]) fail_if( str(stairs) != "Staircase defined by" + f" [NE: (1.0, 1.0)" + f", SE: (1.0, 0.0)" + f", SW: (0.0, 0.0)" + f", NW: (0.0, 1.0)]")
def test_room_node(): rn = RoomNode(vector=Vector(0, 0), room_type=RoomType.kitchen) print(str(rn)) fail_if( str(rn) != f"RoomNode {Node.node_counter - 1} - RoomType.kitchen - " + f"{Vector(0,0)}") rn2 = RoomNode(vector=Vector(0, 0), room_type=RoomType.kitchen) fail_if(rn != rn) fail_if(rn == rn2)
def add_corner(self, points: List[Tuple[int, int]]): cur_x, cur_y = points[0] node = Node(Vector(cur_x, cur_y)) prev_x, prev_y = self.corners[-1] if abs(cur_x - prev_x) < abs(cur_y - prev_y): self.corners.append((prev_x, cur_y)) else: self.corners.append((cur_x, prev_y))
def add_adj_room( floor_plan: FloorPlan, corners: List[Node], room_type: RoomType, name, midpoint: Tuple[float, float] ) -> Tuple[FloorPlan, Tuple[Node, Node, Node, Node]]: node_a = corners[0] node_b = corners[1] node_c = corners[2] node_d = corners[3] room_node = RoomNode(Vector(midpoint[0], midpoint[1]), room_type=RoomType.staircase) edge_a = Edge(edge_type=EdgeType.wall, node_a=node_a, node_b=node_b) edge_b = Edge(edge_type=EdgeType.wall, node_a=node_b, node_b=node_c) edge_c = Edge(edge_type=EdgeType.wall, node_a=node_c, node_b=node_d) edge_d = Edge(edge_type=EdgeType.wall, node_a=node_d, node_b=node_a) edge_la = Edge(edge_type=EdgeType.wall, node_a=node_a, node_b=room_node) edge_lb = Edge(edge_type=EdgeType.wall, node_a=node_b, node_b=room_node) edge_lc = Edge(edge_type=EdgeType.wall, node_a=node_c, node_b=room_node) edge_ld = Edge(edge_type=EdgeType.wall, node_a=node_d, node_b=room_node) node_a.add_edge(edge_a) node_a.add_edge(edge_d) node_a.add_edge(edge_la) node_b.add_edge(edge_a) node_b.add_edge(edge_b) node_b.add_edge(edge_lb) node_c.add_edge(edge_b) node_c.add_edge(edge_c) node_c.add_edge(edge_lc) node_d.add_edge(edge_c) node_d.add_edge(edge_d) node_d.add_edge(edge_ld) room = Room(corners=[node_a, node_b, node_c, node_d], name=name, room_node=room_node) floor_plan.add_node(node_a) floor_plan.add_node(node_b) floor_plan.add_node(node_c) floor_plan.add_node(node_d) floor_plan.add_node(room_node) floor_plan.add_edge(edge_a) floor_plan.add_edge(edge_b) floor_plan.add_edge(edge_c) floor_plan.add_edge(edge_d) floor_plan.add_edge(edge_la) floor_plan.add_edge(edge_lb) floor_plan.add_edge(edge_lc) floor_plan.add_edge(edge_ld) floor_plan.add_room(room) return floor_plan, (node_a, node_b, node_c, node_d)
def house_32_floor_0(): floor_plan = FloorPlan('house_32_floor_0', status=FloorPlanStatus.start) # origin = (6, 7) # footprint floor_plan, (node_a, node_b) = add_wall(floor_plan, node_a=Node(Vector(0, 0)), node_b=Node(Vector(58, 0))) floor_plan, (node_a, node_b) = add_wall(floor_plan, node_a=node_b, node_b=Node(Vector(386, 0))) floor_plan, (node_a, node_b) = add_wall(floor_plan, node_a=node_b, node_b=Node(Vector(386, -183))) floor_plan, (node_a, node_b) = add_wall(floor_plan, node_a=node_b, node_b=Node(Vector(184, -183))) floor_plan, (node_a, node_b) = add_wall(floor_plan, node_a=node_b, node_b=Node(Vector(184, -165))) floor_plan, (node_a, node_b) = add_wall(floor_plan, node_a=node_b, node_b=Node(Vector(127, -165))) floor_plan, (node_a, node_b) = add_wall(floor_plan, node_a=node_b, node_b=Node(Vector(127, -183))) floor_plan, (node_a, node_b) = add_wall(floor_plan, node_a=node_b, node_b=Node(Vector(14, -183))) floor_plan, (node_a, node_b) = add_wall(floor_plan, node_a=node_b, node_b=Node(Vector(14, -77))) floor_plan, (node_a, node_b) = add_wall(floor_plan, node_a=node_b, node_b=Node(Vector(56, -77))) floor_plan, (node_a, node_b) = add_wall(floor_plan, node_a=node_b, node_b=Node(Vector(58, 0))) floor_plan, (node_a, node_b, node_c, node_d) = add_room(floor_plan, corners=[ Node(Vector(134, 0)), Node(Vector(201, 0)), Node(Vector(201, -77)), Node(Vector(134, -77)) ], room_type=RoomType.staircase, name='stairs', midpoint=(167.5, -38.5)) floor_plan, (node_a, node_b, node_c, node_d) = add_room( floor_plan, corners=[node_b, Node(Vector(254, 0)), Node(Vector(254, -77)), node_c], room_type=RoomType.bath, name='stairs', midpoint=(227.5, -38.5)) floor_plan, (node_a, node_b, node_c, node_d) = add_room( floor_plan, corners=[node_b, Node(Vector(341, 0)), Node(Vector(341, -77)), node_c], room_type=RoomType.bed, name='stairs', midpoint=(297.5, -38.5))
def test_door(): bl = Node(Vector(0.0, 0.0)) tl = Node(Vector(0.0, 1.0)) br = Node(Vector(1.0, 0.0)) tr = Node(Vector(1.0, 1.0))
def test_window(): bl = Node(Vector(0.0, 0.0)) tl = Node(Vector(0.0, 1.0)) br = Node(Vector(1.0, 0.0)) tr = Node(Vector(1.0, 1.0))
def test_rectangle(): bl = Node(Vector(0, 0)) tl = Node(Vector(0, 1)) br = Node(Vector(1, 0)) tr = Node(Vector(1, 1)) try: Rectangle([bl, tl]) pytest.fail() except ValueError: pass try: Rectangle([bl, tl, tr, 0]) pytest.fail() except ValueError: pass try: Rectangle([bl, tl, tr, tl]) pytest.fail() except ValueError: pass rectangle = Rectangle([tl, bl, tr, br]) fail_if(rectangle.NE != tr) fail_if(rectangle.SE != br) fail_if(rectangle.SW != bl) fail_if(rectangle.NW != tl) fail_if(rectangle.NE.vector.x != rectangle.SE.vector.x or rectangle.NW.vector.x != rectangle.SW.vector.x or rectangle.NE.vector.y != rectangle.NW.vector.y or rectangle.SE.vector.y != rectangle.SW.vector.y) fail_if(rectangle.width != 1) fail_if(rectangle.height != 1) fail_if(rectangle.is_vertical) fail_if(rectangle.is_horizontal) fail_if(not rectangle.is_square) bl = Node(Vector(0, 0)) tl = Node(Vector(0, 2)) br = Node(Vector(1, 0)) tr = Node(Vector(1, 2)) rectangle2 = Rectangle([tl, bl, tr, br]) fail_if(not rectangle2.is_vertical) fail_if(rectangle2.is_horizontal) fail_if(rectangle2.is_square) fail_if(rectangle2.width != 1) fail_if(rectangle2.height != 2) bl = Node(Vector(0, 0)) tl = Node(Vector(0, 1)) br = Node(Vector(2, 0)) tr = Node(Vector(2, 1)) rectangle3 = Rectangle([tl, bl, tr, br]) fail_if(rectangle3.is_vertical) fail_if(not rectangle3.is_horizontal) fail_if(rectangle3.is_square) fail_if(rectangle3.width != 2) fail_if(rectangle3.height != 1) fail_if(rectangle != rectangle) fail_if(rectangle == rectangle3) # check overlap bl = Node(Vector(0, 0)) tl = Node(Vector(0, 10)) br = Node(Vector(10, 0)) tr = Node(Vector(10, 10)) rectangle = Rectangle([tl, bl, tr, br]) bl = Node(Vector(5, 5)) tl = Node(Vector(5, 15)) br = Node(Vector(15, 5)) tr = Node(Vector(15, 15)) rectangle2 = Rectangle([tl, bl, tr, br]) bl = Node(Vector(-5, -5)) tl = Node(Vector(-5, 5)) br = Node(Vector(5, -5)) tr = Node(Vector(5, 5)) rectangle3 = Rectangle([tl, bl, tr, br]) bl = Node(Vector(5, 5)) tl = Node(Vector(5, 15)) br = Node(Vector(15, 5)) tr = Node(Vector(15, 15)) rectangle4 = Rectangle([tl, bl, tr, br]) bl = Node(Vector(5, -5)) tl = Node(Vector(5, 1)) br = Node(Vector(10, -5)) tr = Node(Vector(10, 1)) rectangle5 = Rectangle([tl, bl, tr, br]) bl = Node(Vector(100, 100)) tl = Node(Vector(100, 110)) br = Node(Vector(110, 100)) tr = Node(Vector(110, 110)) rectangle6 = Rectangle([tl, bl, tr, br]) fail_if(not rectangle.overlap_with(rectangle)) fail_if(not rectangle.overlap_with(rectangle2)) fail_if(not rectangle.overlap_with(rectangle3)) fail_if(not rectangle.overlap_with(rectangle4)) fail_if(not rectangle.overlap_with(rectangle5)) fail_if(rectangle.overlap_with(rectangle6)) try: rectangle.overlap_with(0) pytest.fail() except Exception: pass fail_if(not rectangle.contains_node(Node(Vector(0, 0.5)))) fail_if(rectangle.contains_node(Node(Vector(0, 100))))
def test_line(): vector = Vector(0, 0) vector2 = Vector(2, 2) vector3 = Vector(0, 1) line = Line(vector, vector2, 2) line2 = Line(vector, vector3, 2) fail_if(str(line) != f'Line from {vector} to {vector2}') fail_if(line != line) fail_if(line == line2) fail_if(line.midpoint != Vector(1, 1)) fail_if(line.midpoint != vector.linear_combination(vector2, 0.5)) fail_if(line.left_vector != vector) fail_if(line.right_vector != vector2) fail_if(line.upper_vector != vector2) fail_if(line.bottom_vector != vector) fail_if(line.is_horizontal) fail_if(line.is_vertical) fail_if(line.m != 1.0) fail_if(line.b != 0.0) fail_if(abs(line2) != 1.0) fail_if(line2.left_vector is not None) fail_if(line2.right_vector is not None) fail_if(line2.upper_vector != vector3) fail_if(line2.bottom_vector != vector) fail_if(line2.is_horizontal) fail_if(not line2.is_vertical) fail_if(line2.m != float('Inf')) fail_if(line2.b != float('Inf')) fail_if(not line.contains(vector, 0)) fail_if(not line.contains(vector, 10)) try: line.contains(0, 0) pytest.fail() except ValueError: pass fail_if(not line2.contains(Vector(0, 0.5), 0)) fail_if(not line.is_on_midpoint(Vector(1, 1), 0)) fail_if(not line.is_on_midpoint(Vector(1, 1), 10)) fail_if(line.is_on_midpoint(Vector(1, 2), 0)) fail_if(not line.is_on_midpoint(Vector(1, 2), 1)) try: line.is_on_midpoint(0, 0) pytest.fail() except ValueError: pass
def test_vector(): vector = Vector(0, 0) fail_if(vector.x != 0) fail_if(vector.y != 0) fail_if(vector != Vector(0, 0)) fail_if(vector.left_of(Vector(-1, 0)) != 0) fail_if(vector.left_of(Vector(1, 0)) != 1) fail_if(vector.left_of(Vector(0, 1)) != -1) try: vector.left_of((0, 0)) pytest.fail() except ValueError: pass try: vector.right_of((0, 0)) pytest.fail() except ValueError: pass try: vector.above((0, 0)) pytest.fail() except ValueError: pass try: vector.beneath((0, 0)) pytest.fail() except ValueError: pass fail_if(vector.right_of(Vector(-1, 0)) != 1) fail_if(vector.right_of(Vector(1, 0)) != 0) fail_if(vector.right_of(Vector(0, -1)) != -1) fail_if(vector.beneath(Vector(0, 1)) != 1) fail_if(vector.beneath(Vector(0, -1)) != 0) fail_if(vector.beneath(Vector(1, 0)) != -1) fail_if(vector.above(Vector(0, 1)) != 0) fail_if(vector.above(Vector(0, -1)) != 1) fail_if(vector.above(Vector(-1, 0)) != -1) vector2 = Vector(1, 1) fail_if(vector.distance_to(vector2) != math.sqrt(2)) try: vector.distance_to((0, 0)) pytest.fail() except ValueError: pass lc = vector.linear_combination(vector2, 2) fail_if(lc != Vector(2, 2)) lc = vector2.linear_combination(vector2, 2, 3) fail_if(lc != Vector(5, 5)) try: vector.linear_combination((0, 0), 1) pytest.fail() except ValueError: pass fail_if(vector2 + vector2 != Vector(2, 2)) fail_if(vector2 + vector2 == Vector(3, 2)) try: vector2 + (0, 0) pytest.fail() except ValueError: pass
def test_node_and_edge(): Node.node_counter = 0 vector = Vector(0, 0) node = Node(vector) fail_if(len(node.neighbour_edges) != 8) # fail_if(sum([arg is not None for arg in node.neighbour_edges]) != 0) fail_if(node.vector != vector) print(node.node_count) fail_if(node.node_count != 0) fail_if(Node.node_counter != 1) fail_if(str(node) != f"Node 0 - @ {str(vector)}") # that this shouldn't be allowed when building the graph, but ok for now node2 = Node(vector) fail_if(node2.node_count != 1) fail_if(Node.node_counter != 2) fail_if(node != node) fail_if(node2 != node2) fail_if(node.vector != node2.vector) try: Node(0, 0) pytest.fail() except Exception: pass # directions fail_if(node.left_of(Node(Vector(-1, 0)))) fail_if(not node.left_of(Node(Vector(1, 1)))) fail_if(node.right_of(Node(Vector(1, 0)))) fail_if(not node.right_of(Node(Vector(-1, 0)))) fail_if(node.above(Node(Vector(1, 1)))) fail_if(not node.above(Node(Vector(1, -1)))) fail_if(node.beneath(Node(Vector(0, -1)))) fail_if(not node.beneath(Node(Vector(0, 1)))) # direction to fail_if(node.get_direction_to(Node(Vector(0, 1))) != EdgeDirection('N')) fail_if(node.get_direction_to(Node(Vector(1, 0))) != EdgeDirection('E')) fail_if(node.get_direction_to(Node(Vector(1, 1))) != EdgeDirection('NE')) fail_if(node.get_direction_to(Node(Vector(0, -1))) != EdgeDirection('S')) fail_if(node.get_direction_to(Node(Vector(-1, 0))) != EdgeDirection('W')) fail_if(node.get_direction_to(Node(Vector(-1, -1))) != EdgeDirection('SW')) fail_if(node.get_direction_to(Node(Vector(-1, 1))) != EdgeDirection('NW')) fail_if(node.get_direction_to(Node(Vector(1, -1))) != EdgeDirection('SE')) # SOME EDGE STUFF node2 = Node(Vector(0, 1)) direction = EdgeDirection('N') to = node.get_direction_to(node2) fail_if(to != direction) fail_if(direction.reverse() != EdgeDirection('S')) fail_if(node2.get_direction_to(node) != direction.reverse()) et = EdgeType.wall edge = Edge(edge_type=et, node_a=node, node_b=node2) try: Edge(edge_type=et, node_a=node, node_b=node) pytest.fail() except ValueError: pass node.add_edge(edge) node2.add_edge(edge) try: node.add_edge(edge) pytest.fail() except ValueError: pass try: node.add_edge(0) pytest.fail() except ValueError: pass fail_if(edge.midpoint != Vector(0, 0.5)) fail_if(node.neighbour_edges[0] != edge) fail_if(node2.neighbour_edges[4] != edge) fail_if(node.neighbour_edges['N'] != edge) fail_if(node2.neighbour_edges['S'] != edge) fail_if(edge.get_other_node(node) != node2) fail_if(edge.get_other_node(node2) != node) fail_if(edge.get_upper_node() != node2) fail_if(edge.get_bottom_node() != node) fail_if(edge.get_right_node() is not None) fail_if(edge.get_left_node() is not None) fail_if(edge.is_horizontal()) fail_if(not edge.is_vertical()) fail_if(node.get_neighbour_edge(EdgeDirection('N')) != edge) fail_if(node.get_neighbour_node(EdgeDirection('N')) != node2) try: node.get_neighbour_edge('N') pytest.fail() except ValueError: pass try: node.get_neighbour_node('N') pytest.fail() except ValueError: pass try: Edge(edge_type='N', node_a=node, node_b=node) pytest.fail() except ValueError: pass try: str(edge) except Exception: pytest.fail() fail_if(abs(edge) != 1.0)
def test_floor_plan_nodes(): name = 'test' status = FloorPlanStatus.start fp = FloorPlan(name, status) vector_orig = Vector(0, 0) node = Node(vector_orig) fp.add_node(node) vector2 = Vector(0, 1) try: fp.add_node(vector2) pytest.fail() except ValueError: pass fail_if(fp.nodes[str(vector_orig)] != node) # can't add a duplicate node/vector location fail_if(fp.add_node(node)) try: fp.remove_node(Vector(0, 0)) pytest.fail() except ValueError: pass fail_if(not fp.remove_node(node)) # doesn't exist fail_if(fp.remove_node(Node(Vector(0, 100)))) fp.add_node(node) fail_if(fp.get_node(vector_orig) is None) fail_if(fp.get_node(Vector(0, 100)) is not None) try: fp.get_node((0, 0)) pytest.fail() except ValueError: pass fail_if(not fp.node_exists(node)) fail_if(not fp.node_exists(vector_orig)) try: fp.node_exists((0, 0)) pytest.fail() except ValueError: pass _, exists = fp.nodes_exist([node]) fail_if(not exists) _, exists = fp.nodes_exist([node, vector_orig]) fail_if(not exists) _, exists = fp.nodes_exist([node, Vector(0, 100)]) fail_if(exists) try: fp.nodes_exist([node, (0, 0)]) pytest.fail() except ValueError: pass try: fp.nodes_exist((0, 0)) pytest.fail() except ValueError: pass try: fp.nodes_exist(node) pytest.fail() except ValueError: pass # test update node, ret = fp.update_node_vector(node, vector2) fail_if(not ret) fail_if(node.vector == vector_orig) fail_if(node.vector != vector2) fail_if(str(vector_orig) in fp.nodes) fail_if(not str(vector2) in fp.nodes) fail_if(fp.get_node(vector2) != node) fail_if(fp.nodes[str(vector2)].vector != vector2) fail_if(len(fp.nodes) != 1) try: fp.update_node_vector(node, (0, 0)) pytest.fail() except ValueError: pass fail_if(fp.update_node_vector(Node(Vector(0, 100)), Vector(0, 300)))
def test_floor_plan_edges(): name = 'test' status = FloorPlanStatus.start fp = FloorPlan(name, status) node = Node(Vector(0, 1)) node_b = Node(Vector(0, 2)) fp.add_node(node) fp.add_node(node_b) edge = Edge(edge_type=EdgeType.wall, node_a=node, node_b=node_b) node.add_edge(edge) node_b.add_edge(edge) fail_if(fp.get_node(Vector(0, 1)).neighbour_edges[0] != edge) fail_if(fp.get_node(Vector(0, 1)).neighbour_edges[0].upper_node != node_b) fail_if(fp.get_node(Vector(0, 1)).neighbour_edges[0].bottom_node != node) fp.add_edge(edge) fail_if(fp.edges[f'{node}_{node.get_direction_to(node_b)}'] != edge) fail_if(fp.edges[f'{node_b}_{node_b.get_direction_to(node)}'] != edge) fail_if(fp.edges[str(edge)] != edge) try: fp.add_edge(0) pytest.fail() except ValueError: pass try: fp.remove_edge(0) pytest.fail() except ValueError: pass fail_if(not fp.remove_edge(edge)) fp.add_edge(edge) node_3 = Node(Vector(0, 10)) node_4 = Node(Vector(0, 30)) edge2 = Edge(EdgeType.wall, node_a=node_3, node_b=node_4) fail_if(fp.remove_edge(edge2)) fp.add_edge(edge2) fail_if(len(fp.edges) != 2) fail_if(fp.edges[f'{node}_{node.get_direction_to(node_b)}'] != edge) fail_if(fp.edges[f'{node_b}_{node_b.get_direction_to(node)}'] != edge) fail_if(fp.edges[str(edge)] != edge) fail_if(fp.edges[f'{node_3}_{node_3.get_direction_to(node_4)}'] == edge) fail_if(fp.edges[f'{node_3}_{node_3.get_direction_to(node_4)}'] != edge2) fail_if(fp.edges[f'{node_4}_{node_4.get_direction_to(node_3)}'] != edge2) fail_if(fp.edges[str(edge2)] != edge2) fail_if(not fp.edge_exists(edge)) fail_if(not fp.edge_exists(edge2)) edge3 = Edge(EdgeType.wall, node_a=node, node_b=node_4) fail_if(fp.edge_exists(edge3)) try: fp.edge_exists(0) pytest.fail() except ValueError: pass _, ret = fp.edges_exist([edge, edge2]) fail_if(not ret) edge_ret, ret = fp.edges_exist([edge, edge2, edge3]) fail_if(ret) fail_if(edge_ret != edge3) try: _, ret = fp.edges_exist([edge, edge2, 0]) pytest.fail() except ValueError: pass try: _, ret = fp.edges_exist(edge) pytest.fail() except ValueError: pass node_4 = Node(Vector(0, -10)) edge = Edge(EdgeType.wall, node_a=node, node_b=node_4) fail_if(node.neighbour_edges[node.get_direction_to(node_4).integer_value] is not None) fp.add_edge(edge) node.add_edge(edge) node_4.add_edge(edge) fail_if(node.neighbour_edges[node.get_direction_to( node_4).integer_value] is None) print(fp.nodes) fail_if(fp.nodes[str(node.vector)].neighbour_edges[ node.get_direction_to(node_4).integer_value] != edge)