def test_init(self): name = ["ICE", "AIR"] emblem = ["MAMMOTH", "OWL"] ice_kingdom = Kingdom(name[0], emblem[0]) air_kingdom = Kingdom(name[1], emblem[1]) message_text = "ROZO" message = Message(air_kingdom, ice_kingdom, message_text) self.assertIsInstance(message, Message)
def test_get_message(self): name = ["ICE", "AIR"] emblem = ["MAMMOTH", "OWL"] ice_kingdom = Kingdom(name[0], emblem[0]) air_kingdom = Kingdom(name[1], emblem[1]) message_text = "ROZO" message = Message(air_kingdom, ice_kingdom, message_text) self.assertEqual(message.get_message(), message_text) Kingdom.remove_all_kingdoms()
def test_add_ally_and_is_ally(self): name = ["ICE", "AIR", "WATER"] emblem = ["MAMMOTH", "OWL", "OCTOPUS"] ice_kingdom = Kingdom(name[0], emblem[0]) air_kingdom = Kingdom(name[1], emblem[1]) water_kingdom = Kingdom(name[2], emblem[2]) ice_kingdom.add_ally(air_kingdom) self.assertTrue(ice_kingdom.is_ally(air_kingdom)) self.assertTrue(air_kingdom.is_ally(ice_kingdom)) self.assertFalse(water_kingdom.is_ally(ice_kingdom)) Kingdom.remove_all_kingdoms()
def test_ally_count(self): name = ["ICE", "AIR", "WATER"] emblem = ["MAMMOTH", "OWL", "OCTOPUS"] ice_kingdom = Kingdom(name[0], emblem[0]) air_kingdom = Kingdom(name[1], emblem[1]) water_kingdom = Kingdom(name[2], emblem[2]) ice_kingdom.add_ally(air_kingdom) ice_kingdom.add_ally(water_kingdom) self.assertEqual(2, ice_kingdom.total_allies()) self.assertEqual(1, water_kingdom.total_allies()) self.assertNotEqual(2, air_kingdom.total_allies()) Kingdom.remove_all_kingdoms()
def test_send_message(self): name = ["ICE", "AIR"] emblem = ["MAMMOTH", "OWL"] ice_kingdom = Kingdom(name[0], emblem[0]) air_kingdom = Kingdom(name[1], emblem[1]) message_text = "ROZO" message = Message(air_kingdom, ice_kingdom, message_text) response = air_kingdom.send_message(message) self.assertFalse(response) message = Message(ice_kingdom, air_kingdom, message_text) response = ice_kingdom.send_message(message) self.assertTrue(response) Kingdom.remove_all_kingdoms()
def test_check_ruler(self): name = ["ICE", "AIR", "WATER", "FIRE"] emblem = ["MAMMOTH", "OWL", "OCTOPUS", "DRAGON"] ice_kingdom = Kingdom(name[0], emblem[0]) air_kingdom = Kingdom(name[1], emblem[1]) water_kingdom = Kingdom(name[2], emblem[2]) fire_kingdom = Kingdom(name[3], emblem[3]) ice_kingdom.add_ally(air_kingdom) ice_kingdom.add_ally(water_kingdom) ice_kingdom.add_ally(air_kingdom) ice_kingdom.add_ally(fire_kingdom) self.assertTrue(ice_kingdom.is_ruler()) self.assertFalse(fire_kingdom.is_ruler()) Kingdom.remove_all_kingdoms()
def test_get_ruler(self): name = ["ICE", "AIR", "WATER", "FIRE"] emblem = ["MAMMOTH", "OWL", "OCTOPUS", "DRAGON"] ice_kingdom = Kingdom(name[0], emblem[0]) air_kingdom = Kingdom(name[1], emblem[1]) water_kingdom = Kingdom(name[2], emblem[2]) fire_kingdom = Kingdom(name[3], emblem[3]) ice_kingdom.add_ally(air_kingdom) self.assertIsNone(Kingdom.get_ruler()) ice_kingdom.add_ally(water_kingdom) ice_kingdom.add_ally(air_kingdom) ice_kingdom.add_ally(fire_kingdom) self.assertEqual(ice_kingdom, Kingdom.get_ruler()) self.assertNotEqual(fire_kingdom, Kingdom.get_ruler()) Kingdom.remove_all_kingdoms()
def main(): input_file = sys.argv[1] data = ir.read_input(input_file) messages = ir.validate_format(config_data.get("std_input_format"), data) home_kingdom = config_data.get("home_kingdom") home_kngdm_obj = Kingdom(home_kingdom) home_kngdm_obj.send_secret_msg(messages) allies = home_kngdm_obj.form_rule() output = op.Outputter(allies) output.print_standard_output()
def test_verify(self): name = "AIR" emblem = "OWL" air_kingdom = Kingdom(name, emblem) message_text = "ROZO" response = MessageVerify.verify(air_kingdom, message_text) self.assertTrue(response) message_text = "OWLAOWLBOWLC" response = MessageVerify.verify(air_kingdom, message_text) self.assertFalse(response) Kingdom.remove_all_kingdoms()
def register_kingdom(self, name, emblem): """Creates a Kingdom Class for the given kingdom name and emblem Args: name (string): Name of the Kingdom emblem (string): Emblem of the Kingdom Returns: Kingdom Object: Return the new kingdom object """ new_kingdom = Kingdom(name, emblem) self.__kingdom_count += 1 return new_kingdom
def generate_kingdom(): new_kingdom = {0: 30, 1: 30, 2: 30, 3: 8, 4: 8, 5: 8, 6: 10} # TODO eventually need to randomly select 10 cards for the kingdom for i in range(7, params.max_card_id + 1): if random.random() < 1: new_kingdom[i] = 10 else: new_kingdom[i] = 0 # new_kingdom[9] = 1 return Kingdom(new_kingdom)
def _get_field_names(cls_name): lookup = { 'Republic': Republic(), 'Monarchy': Monarchy(), 'Kingdom': Kingdom(), 'State': State() } my_dict = lookup[cls_name].__dict__ present_field = [] is_callable = (types.FunctionType, types.MethodType) i = 1 for key, value in my_dict.items(): if not isinstance(value, is_callable): present_field.append(key) ind = key.rindex("__") key = key[ind + 2:len(key)] print("{0} - {1}".format(i, key)) i += 1 return present_field
def _create_kingdom_instance(words): kingdom = Kingdom(int(words[0]), float(words[1]), words[2], words[3]) return kingdom
def _setUp(self): self.kingdom_obj = Kingdom("KINGDOMONE")
def test_init(self): name = "ICE" emblem = "MAMMOTH" ice_kingdom = Kingdom(name, emblem) self.assertIsInstance(ice_kingdom, Kingdom) Kingdom.remove_all_kingdoms()
def test_name(self): name = "ICE" emblem = "MAMMOTH" ice_kingdom = Kingdom(name, emblem) self.assertEqual(name, ice_kingdom.name()) Kingdom.remove_all_kingdoms()
def test_get_kingdom(self): name = "ICE" emblem = "MAMMOTH" ice_kingdom = Kingdom(name, emblem) self.assertEqual(ice_kingdom, Kingdom.get_kingdom(name)) Kingdom.remove_all_kingdoms()
def test_emblem_length(self): name = "ICE" emblem = "MAMMOTH" ice_kingdom = Kingdom(name, emblem) self.assertEqual(len(emblem), ice_kingdom.emblem_length()) Kingdom.remove_all_kingdoms()