def test_call(self): """ Test calling the tags loader """ vertex = _TestVertex() tag_1 = IPTag("127.0.0.1", 0, 0, 1, "localhost", 12345, True, "Test") tag_2 = IPTag("127.0.0.1", 0, 0, 2, "localhost", 54321, True, "Test") rip_tag_1 = ReverseIPTag("127.0.0.1", 3, 12345, 0, 0, 0, 0) rip_tag_2 = ReverseIPTag("127.0.0.1", 4, 12346, 0, 0, 0, 0) tags = Tags() tags.add_ip_tag(tag_1, vertex) tags.add_ip_tag(tag_2, vertex) tags.add_reverse_ip_tag(rip_tag_1, vertex) tags.add_reverse_ip_tag(rip_tag_2, vertex) txrx = _MockTransceiver() loader = TagsLoader() loader.__call__(txrx, tags) self.assertIn(tag_1, txrx.ip_tags) self.assertIn(tag_2, txrx.ip_tags) self.assertIn(rip_tag_1, txrx.reverse_ip_tags) self.assertIn(rip_tag_2, txrx.reverse_ip_tags)
def test_call(self): """ Test calling the tags loader """ vertex = _TestVertex() tag_1 = IPTag("127.0.0.1", 0, 0, 1, "localhost", 12345, True, "Test") tag_2 = IPTag("127.0.0.1", 0, 0, 2, "localhost", 54321, True, "Test") rip_tag_1 = ReverseIPTag("127.0.0.1", 3, 12345, 0, 0, 0, 0) rip_tag_2 = ReverseIPTag("127.0.0.1", 4, 12346, 0, 0, 0, 0) tags = Tags() tags.add_ip_tag(tag_1, vertex) tags.add_ip_tag(tag_2, vertex) tags.add_reverse_ip_tag(rip_tag_1, vertex) tags.add_reverse_ip_tag(rip_tag_2, vertex) txrx = _MockTransceiver() loader = TagsLoader() loader.__call__(txrx, tags) self.assertIn(tag_1, txrx.ip_tags) self.assertIn(tag_2, txrx.ip_tags) self.assertIn(rip_tag_1, txrx.reverse_ip_tags) self.assertIn(rip_tag_2, txrx.reverse_ip_tags)
def test_adding_a_reverse_iptag(self): """ check that adding a reverse iptag works correctly """ tag_info = Tags() reverse_iptag = ReverseIPTag("", 1, 23, 0, 0, 1, 1) machine_vertex = SimpleMachineVertex(None, "") tag_info.add_reverse_ip_tag(reverse_iptag, machine_vertex)
def test_add_reverse_iptag_then_locate_tag(self): """ check that asking for a reverse iptag for a specific machine vertex works """ tag_info = Tags() reverse_iptag = ReverseIPTag("", 1, 23, 0, 0, 1, 1) machine_vertex = SimpleMachineVertex(None, "") tag_info.add_reverse_ip_tag(reverse_iptag, machine_vertex) gotton_tag = tag_info.get_reverse_ip_tags_for_vertex(machine_vertex) self.assertEqual(gotton_tag[0], reverse_iptag)
def test_add_reverse_iptag_then_not_locate_tag(self): """ check that asking for a reverse iptag with a incorrect machine vertex will cause a none returned """ tag_info = Tags() reverse_iptag = ReverseIPTag("", 1, 23, 0, 0, 1, 1) machine_vertex = SimpleMachineVertex(None, "") machine_vertex2 = SimpleMachineVertex(None, "") tag_info.add_reverse_ip_tag(reverse_iptag, machine_vertex2) gotton_tag = tag_info.get_reverse_ip_tags_for_vertex(machine_vertex) self.assertEqual(gotton_tag, None)
def test_add_conflicting_ip_tag(self): tags = Tags() tag1 = IPTag("", 0, 0, 1, "122.2.2.2", 1, False) tag2 = IPTag("", 0, 7, 1, "122.2.2.3", 1, False) tag3 = ReverseIPTag("", 1, 23, 0, 0, 1, 1) machine_vertex = SimpleMachineVertex(None, "") tags.add_ip_tag(tag1, machine_vertex) with self.assertRaises(PacmanInvalidParameterException) as e: tags.add_ip_tag(tag2, machine_vertex) self.assertIn( "The tag specified has already been assigned with " "different properties", str(e.exception)) with self.assertRaises(PacmanInvalidParameterException) as e: tags.add_reverse_ip_tag(tag3, machine_vertex) self.assertIn("The tag has already been assigned on the given board", str(e.exception)) with self.assertRaises(PacmanInvalidParameterException) as e: tags.add_ip_tag(tag3, machine_vertex) self.assertIn("Only add IP tags with this method.", str(e.exception))