def setUp(self): card_repository.delete_all() self.card1 = Card('Teemu Kerppu') self.card2 = Creature('Kana') self.card3 = Instant('Kortti') self.card4 = Creature('Kana2') self.card1.set_cubes(["id1"]) self.card2.set_cubes(["id1"]) self.card3.set_cubes(["id2"]) self.card4.set_cubes(["id1"])
def create_card_entity_from_db(self, card_row): """ Creates a Card entity from the given database row. Args: card_row: [List Tuple] List of tuples including the attributes of one card in database. Returns: [Card] Created Card entity. """ name = card_row[1] maintype = card_row[3] if maintype == "": card = Card(name) elif maintype == "Creature": card = Creature(name) elif maintype == "Artifact": card = Artifact(name) elif maintype == "Enchantment": card = Enchantment(name) elif maintype == "Land": card = Land(name) elif maintype == "Instant": card = Instant(name) elif maintype == "Sorcery": card = Sorcery(name) elif maintype == "Planeswalker": card = Planeswalker(name) elif maintype == "Artifact Creature": card = ArtifactCreature(name) elif maintype == "Enchantment Creature": card = EnchantmentCreature(name) card.set_id(card_row[0]) card.set_cubes(card_row[2]) card.set_legendary(card_row[4]) card.set_tribal(card_row[5]) card.set_subtype(card_row[6]) card.set_colour(card_row[7]) card.set_manacost(card_row[8]) card.set_feature(card_row[9]) card.set_ruletext(card_row[10]) card.set_flavourtext(card_row[11]) card.set_power(card_row[12]) card.set_toughness(card_row[13]) card.set_image(card_row[14]) card.set_seticon(card_row[15]) card.set_rarity(card_row[16]) card.set_creator(card_row[17]) card.set_picture(card_row[18]) return card
def test_copy_creature(self): self.set_card() creature = Creature(self.card.get_name()) creature.copy(self.card) self.assertEqual(creature.get_id(), "1234567") self.assertEqual(creature.get_name(), "Party Tutor") self.assertEqual(creature.get_image(), "img/partytutor") self.assertEqual(creature.get_maintype(), "Creature") self.assertEqual(creature.get_legendary(), False) self.assertEqual(creature.get_tribal(), None) self.assertEqual(creature.get_subtype(), ["Teekkari", "ISO"]) self.assertEqual(creature.get_colour(), ["Vihreä"]) self.assertEqual(creature.get_manacost(), "2U") self.assertEqual(creature.get_power(), 3) self.assertEqual(creature.get_toughness(), 2) self.assertEqual(creature.get_feature(), ["Haste", "Trample"]) self.assertEqual(creature.get_feature2(), []) self.assertEqual(creature.get_ruletext(), "Party Tutor rule") self.assertEqual(creature.get_flavourtext(), "Party") self.assertEqual(creature.get_creator(), "Masa") self.assertEqual(creature.get_seticon(), "img/seticon1") self.assertEqual(creature.get_rarity(), "Common")
def setUp(self): self.card = Card('Graduated friend') self.creature = Creature('Teemu K')
class TestCard(unittest.TestCase): def setUp(self): self.card = Card('Graduated friend') self.creature = Creature('Teemu K') ### def set_card(self): self.card.set_id("1234567") self.card.set_name("Party Tutor") self.card.set_cubes(["123", "234"]) self.card.set_maintype("Creature") self.card.set_legendary(False) self.card.set_tribal(True) self.card.set_subtype("Teekkari ISO") self.card.set_colour("Vihreä") self.card.set_manacost("2U") self.card.set_power(3) self.card.set_toughness(2) self.card.set_feature("Haste, Trample") self.card.set_ruletext("Party Tutor rule") self.card.set_flavourtext("Party") self.card.set_image("img/partytutor") self.card.set_creator("Masa") self.card.set_seticon("img/seticon1") self.card.set_rarity("Common") def test_set_attributes(self): self.set_card() self.assertEqual(self.card.get_id(), "1234567") self.assertEqual(self.card.get_name(), "Party Tutor") self.assertEqual(self.card.get_cubes(), ["123", "234"]) self.assertEqual(self.card.get_maintype(), "Creature") self.assertEqual(self.card.get_legendary(), False) self.card.set_legendary(None) self.assertEqual(self.card.get_legendary(), False) self.assertEqual(self.card.get_tribal(), True) self.assertEqual(self.card.get_subtype(), ["Teekkari", "ISO"]) self.card.set_subtype(None) self.assertEqual(self.card.get_subtype(), ["Teekkari", "ISO"]) self.assertEqual(self.card.get_colour(), ["Vihreä"]) self.card.set_colour("Väritön") self.assertEqual(self.card.get_colour(), []) self.assertEqual(self.card.get_manacost(), "2U") self.assertEqual(self.card.get_power(), 3) self.assertEqual(self.card.get_toughness(), 2) self.assertEqual(self.card.get_feature(), ["Haste", "Trample"]) self.assertEqual(self.card.get_ruletext(), "Party Tutor rule") self.assertEqual(self.card.get_flavourtext(), "Party") self.assertEqual(self.card.get_image(), "img/partytutor") self.assertEqual(self.card.get_creator(), "Masa") self.assertEqual(self.card.get_seticon(), "img/seticon1") self.assertEqual(self.card.get_rarity(), "Common") def test_get_cubes_print(self): self.assertEqual(self.card.get_cubes_print(), "") self.card.set_cubes(["1234", "2345"]) self.assertEqual(self.card.get_cubes_print(), "1234, 2345") self.card.set_cubes("9876") self.assertEqual(self.card.get_cubes_print(), "9876") def test_get_legendary_print(self): self.assertEqual(self.card.get_legendary_print(), "") self.card.set_legendary(True) self.assertEqual(self.card.get_legendary_print(), "Legendary ") self.card.set_legendary(False) self.assertEqual(self.card.get_legendary_print(), "") def test_get_tribal_print(self): self.assertEqual(self.card.get_tribal_print(), "") self.card.set_tribal(True) self.assertEqual(self.card.get_tribal_print(), "Tribal ") self.card.set_tribal(False) self.assertEqual(self.card.get_tribal_print(), "") def test_get_subtype_print(self): self.assertEqual(self.card.get_subtype_print(), "") self.card.set_subtype("Beast Bird") self.assertEqual(self.card.get_subtype_print(), "Beast Bird") self.card.set_subtype("Bird") self.assertEqual(self.card.get_subtype_print(), "Bird") def test_add_cube(self): self.assertEqual(self.card.get_cubes(), []) self.card.add_cube("999") self.assertEqual(self.card.get_cubes(), ["999"]) self.card.add_cube("777") self.assertEqual(self.card.get_cubes(), ["999", "777"]) self.card.add_cube("999") self.assertEqual(self.card.get_cubes(), ["999", "777"]) self.card.add_cube("111") self.assertEqual(self.card.get_cubes(), ["999", "777", "111"]) def test_add_colour(self): self.card.add_colour("Punainen") self.assertEqual(self.card.get_colour(), ["Punainen"]) self.card.add_colour("Valkoinen") self.assertEqual(self.card.get_colour(), ["Punainen", "Valkoinen"]) self.card.add_colour("Valkoinen") self.assertEqual(self.card.get_colour(), ["Punainen", "Valkoinen"]) self.card.add_colour("Sininen") self.assertEqual(self.card.get_colour(), ["Punainen", "Valkoinen", "Sininen"]) def test_remove_cube(self): self.card.remove_cube("123") self.assertEqual(self.card.get_cubes(), []) self.card.add_cube("123") self.card.add_cube("4321") self.card.remove_cube("1234") self.assertEqual(self.card.get_cubes(), ["123", "4321"]) self.card.remove_cube("123") self.assertEqual(self.card.get_cubes(), ["4321"]) self.card.remove_cube("1") self.assertEqual(self.card.get_cubes(), ["4321"]) self.card.remove_cube("4321") self.assertEqual(self.card.get_cubes(), []) self.card.remove_cube("4321") self.assertEqual(self.card.get_cubes(), []) def test_remove_colour(self): self.card.add_colour("Punainen") self.card.add_colour("Valkoinen") self.card.remove_colour("Vihreä") self.assertEqual(self.card.get_colour(), ["Punainen", "Valkoinen"]) self.card.remove_colour("Punainen") self.assertEqual(self.card.get_colour(), ["Valkoinen"]) self.card.remove_colour("Valkoinen") self.assertEqual(self.card.get_colour(), []) self.card.remove_colour("Valkoinen") self.assertEqual(self.card.get_colour(), []) def test_get_card_colour(self): self.assertEqual(self.card.get_card_colour(), "Väritön") self.card.add_colour("Punainen") self.assertEqual(self.card.get_card_colour(), "Punainen") self.card.add_colour("Vihreä") self.assertEqual(self.card.get_card_colour(), "Kulta") self.card.remove_colour("Punainen") self.assertEqual(self.card.get_card_colour(), "Vihreä") self.card.remove_colour("Vihreä") self.assertEqual(self.card.get_card_colour(), "Väritön") def test_get_colour_print(self): self.assertEqual(self.card.get_colour_print(), "Väritön") self.card.add_colour("Punainen") self.assertEqual(self.card.get_colour_print(), "Punainen") self.card.add_colour("Vihreä") self.assertEqual(self.card.get_colour_print(), "Punainen, Vihreä") def test_check_if_multicolour(self): self.assertNotEqual(self.card.get_card_colour(), "Kulta") self.card.add_colour("Punainen") self.assertNotEqual(self.card.get_card_colour(), "Kulta") self.card.add_colour("Vihreä") self.assertEqual(self.card.get_card_colour(), "Kulta") self.card.add_colour("Musta") self.assertEqual(self.card.get_card_colour(), "Kulta") self.card.remove_colour("Punainen") self.card.remove_colour("Musta") self.assertNotEqual(self.card.get_card_colour(), "Kulta") def test_get_power_print(self): self.assertEqual(self.card.get_power_print(), 0) self.card.set_power(4) self.assertEqual(self.card.get_power_print(), 4) self.card.set_power(2) self.assertEqual(self.card.get_power_print(), 2) def test_get_toughness_print(self): self.assertEqual(self.card.get_toughness_print(), 0) self.card.set_toughness(10) self.assertEqual(self.card.get_toughness_print(), 10) self.card.set_toughness(1) self.assertEqual(self.card.get_toughness_print(), 1) def test_add_feature(self): self.assertEqual(self.card.get_feature(), []) self.card.add_feature("Flying") self.assertEqual(self.card.get_feature(), ["Flying"]) self.card.add_feature("Vigilance") self.assertEqual(self.card.get_feature(), ["Flying", "Vigilance"]) self.card.add_feature("Vigilance") self.assertEqual(self.card.get_feature(), ["Flying", "Vigilance"]) self.card.add_feature("Trample") self.assertEqual(self.card.get_feature(), ["Flying", "Vigilance", "Trample"]) def test_remove_feature(self): self.card.add_feature("Reach") self.card.add_feature("Deathtouch") self.card.remove_feature("Firststrike") self.assertEqual(self.card.get_feature(), ["Reach", "Deathtouch"]) self.card.remove_feature("Deathtouch") self.assertEqual(self.card.get_feature(), ["Reach"]) self.card.remove_feature("Reach") self.assertEqual(self.card.get_feature(), []) self.card.remove_feature("Reach") self.assertEqual(self.card.get_feature(), []) def test_get_feature_print(self): self.assertEqual(self.card.get_feature_print(), "") self.card.add_feature("Flying") self.card.add_feature("Vigilance") self.assertEqual(self.card.get_feature_print(), "Flying, Vigilance") self.card.add_feature("Trample") self.assertEqual(self.card.get_feature_print(), "Flying, Vigilance, Trample") self.card.remove_feature("Vigilance") self.assertEqual(self.card.get_feature_print(), "Flying, Trample") def test_get_feature_list(self): self.assertEqual(self.card.get_feature_list(), []) self.card.add_feature("Flying") self.card.add_feature("Vigilance") self.assertEqual(self.card.get_feature_list(), ["Flying", "Vigilance"]) self.card.add_feature("Trample") self.assertEqual(self.card.get_feature_list(), ["Flying", "Vigilance", "Trample"]) self.card.remove_feature("Vigilance") self.assertEqual(self.card.get_feature_list(), ["Flying", "Trample"]) def test_show_card(self): self.set_card() self.card.add_colour("Punainen") #self.assertEqual(self.show_card(), ) self.assertEqual(True, True) # Creature def set_creature(self): self.creature.set_id("891234") self.creature.set_name("Teemu Kerppu") self.creature.set_image("img/teemukerppu") self.creature.set_legendary(True) self.creature.set_subtype("DI Spirit") self.creature.set_manacost("2U2") self.creature.set_power(3) self.creature.set_toughness(4) self.creature.set_ruletext("Teemu Kerppu rule") self.creature.set_flavourtext("Imaginary") self.creature.set_creator("Peruna") self.creature.set_seticon("img/seticon1") self.creature.set_rarity("Rare") def test_set_creature(self): self.set_creature() self.assertEqual(self.creature.get_id(), "891234") self.assertEqual(self.creature.get_name(), "Teemu Kerppu") self.assertEqual(self.creature.get_image(), "img/teemukerppu") self.assertEqual(self.creature.get_maintype(), "Creature") self.assertEqual(self.creature.get_legendary(), True) self.assertEqual(self.creature.get_tribal(), None) self.assertEqual(self.creature.get_subtype(), ["DI", "Spirit"]) self.assertEqual(self.creature.get_manacost(), "2U2") self.assertEqual(self.creature.get_power(), 3) self.assertEqual(self.creature.get_toughness(), 4) self.assertEqual(self.creature.get_ruletext(), "Teemu Kerppu rule") self.assertEqual(self.creature.get_flavourtext(), "Imaginary") self.assertEqual(self.creature.get_creator(), "Peruna") self.assertEqual(self.creature.get_seticon(), "img/seticon1") self.assertEqual(self.creature.get_rarity(), "Rare") def test_copy_creature(self): self.set_card() creature = Creature(self.card.get_name()) creature.copy(self.card) self.assertEqual(creature.get_id(), "1234567") self.assertEqual(creature.get_name(), "Party Tutor") self.assertEqual(creature.get_image(), "img/partytutor") self.assertEqual(creature.get_maintype(), "Creature") self.assertEqual(creature.get_legendary(), False) self.assertEqual(creature.get_tribal(), None) self.assertEqual(creature.get_subtype(), ["Teekkari", "ISO"]) self.assertEqual(creature.get_colour(), ["Vihreä"]) self.assertEqual(creature.get_manacost(), "2U") self.assertEqual(creature.get_power(), 3) self.assertEqual(creature.get_toughness(), 2) self.assertEqual(creature.get_feature(), ["Haste", "Trample"]) self.assertEqual(creature.get_feature2(), []) self.assertEqual(creature.get_ruletext(), "Party Tutor rule") self.assertEqual(creature.get_flavourtext(), "Party") self.assertEqual(creature.get_creator(), "Masa") self.assertEqual(creature.get_seticon(), "img/seticon1") self.assertEqual(creature.get_rarity(), "Common") # Artifact def test_copy_artifact(self): self.set_card() k = Artifact(self.card.get_name()) k.copy(self.card) self.assertEqual(k.get_id(), "1234567") self.assertEqual(k.get_name(), "Party Tutor") self.assertEqual(k.get_image(), "img/partytutor") self.assertEqual(k.get_maintype(), "Artifact") self.assertEqual(k.get_legendary(), False) self.assertEqual(k.get_tribal(), True) self.assertEqual(k.get_subtype(), ["Teekkari", "ISO"]) k.set_subtype(None) self.assertEqual(k.get_subtype(), ["Teekkari", "ISO"]) self.assertEqual(k.get_colour(), ["Vihreä"]) self.assertEqual(k.get_manacost(), "2U") self.assertEqual(k.get_power(), None) self.assertEqual(k.get_toughness(), None) self.assertEqual(k.get_feature(), []) k.set_feature(["Haste", "Flash"]) self.assertEqual(k.get_feature(), ["Flash"]) self.assertEqual(k.get_feature2(), ["Hexproof", "Indestructible", "Flash"]) self.assertEqual(k.get_ruletext(), "Party Tutor rule") self.assertEqual(k.get_flavourtext(), "Party") self.assertEqual(k.get_creator(), "Masa") self.assertEqual(k.get_seticon(), "img/seticon1") self.assertEqual(k.get_rarity(), "Common") def test_vehicle_artifact(self): self.set_card() k = Artifact(self.card.get_name()) k.copy(self.card) k.set_subtype("Vehicle") self.assertEqual(k.get_id(), "1234567") self.assertEqual(k.get_name(), "Party Tutor") self.assertEqual(k.get_image(), "img/partytutor") self.assertEqual(k.get_maintype(), "Artifact") self.assertEqual(k.get_legendary(), False) self.assertEqual(k.get_tribal(), True) self.assertEqual(k.get_subtype(), ["Vehicle"]) self.assertEqual(k.get_colour(), ["Vihreä"]) self.assertEqual(k.get_manacost(), "2U") self.assertEqual(k.get_power(), 0) self.assertEqual(k.get_toughness(), 0) self.assertEqual(k.get_feature(), []) self.assertEqual(k.get_feature2(), ["Hexproof", "Indestructible", "Flash"]) self.assertEqual(k.get_ruletext(), "Party Tutor rule") self.assertEqual(k.get_flavourtext(), "Party") self.assertEqual(k.get_creator(), "Masa") self.assertEqual(k.get_seticon(), "img/seticon1") self.assertEqual(k.get_rarity(), "Common") k.set_subtype("Vehicle Bird") self.assertEqual(k.get_id(), "1234567") self.assertEqual(k.get_name(), "Party Tutor") self.assertEqual(k.get_image(), "img/partytutor") self.assertEqual(k.get_maintype(), "Artifact") self.assertEqual(k.get_legendary(), False) self.assertEqual(k.get_tribal(), True) self.assertEqual(k.get_subtype(), ["Vehicle", "Bird"]) self.assertEqual(k.get_colour(), ["Vihreä"]) self.assertEqual(k.get_manacost(), "2U") self.assertEqual(k.get_power(), None) self.assertEqual(k.get_toughness(), None) self.assertEqual(k.get_feature(), []) self.assertEqual(k.get_feature2(), ["Hexproof", "Indestructible", "Flash"]) self.assertEqual(k.get_ruletext(), "Party Tutor rule") self.assertEqual(k.get_flavourtext(), "Party") self.assertEqual(k.get_creator(), "Masa") self.assertEqual(k.get_seticon(), "img/seticon1") self.assertEqual(k.get_rarity(), "Common") def test_feature_artifact(self): self.set_card() k = Artifact(self.card.get_name()) k.copy(self.card) k.add_feature("Trample") self.assertEqual(k.get_feature(), []) k.add_feature("Flash") self.assertEqual(k.get_feature(), ["Flash"]) k.add_feature("Vigilance") self.assertEqual(k.get_feature(), ["Flash"]) k.add_feature("Hexproof") self.assertEqual(k.get_feature(), ["Flash", "Hexproof"]) # Artifact creature def test_copy_artifact_creature(self): self.set_card() k = ArtifactCreature(self.card.get_name()) k.copy(self.card) self.assertEqual(k.get_id(), "1234567") self.assertEqual(k.get_name(), "Party Tutor") self.assertEqual(k.get_image(), "img/partytutor") self.assertEqual(k.get_maintype(), "Artifact Creature") self.assertEqual(k.get_legendary(), False) self.assertEqual(k.get_tribal(), None) self.assertEqual(k.get_subtype(), ["Teekkari", "ISO"]) self.assertEqual(k.get_colour(), ["Vihreä"]) self.assertEqual(k.get_manacost(), "2U") self.assertEqual(k.get_power(), 3) self.assertEqual(k.get_toughness(), 2) self.assertEqual(k.get_feature(), ["Haste", "Trample"]) self.assertEqual(k.get_feature2(), []) self.assertEqual(k.get_ruletext(), "Party Tutor rule") self.assertEqual(k.get_flavourtext(), "Party") self.assertEqual(k.get_creator(), "Masa") self.assertEqual(k.get_seticon(), "img/seticon1") self.assertEqual(k.get_rarity(), "Common") # Enchantment def test_copy_enchantment(self): self.set_card() k = Enchantment(self.card.get_name()) k.copy(self.card) self.assertEqual(k.get_id(), "1234567") self.assertEqual(k.get_name(), "Party Tutor") self.assertEqual(k.get_image(), "img/partytutor") self.assertEqual(k.get_maintype(), "Enchantment") self.assertEqual(k.get_legendary(), False) self.assertEqual(k.get_tribal(), True) self.assertEqual(k.get_subtype(), ["Teekkari", "ISO"]) self.assertEqual(k.get_colour(), ["Vihreä"]) self.assertEqual(k.get_manacost(), "2U") self.assertEqual(k.get_power(), None) self.assertEqual(k.get_toughness(), None) self.assertEqual(k.get_feature(), []) self.assertEqual(k.get_feature2(), ["Hexproof", "Indestructible", "Flash"]) self.assertEqual(k.get_ruletext(), "Party Tutor rule") self.assertEqual(k.get_flavourtext(), "Party") self.assertEqual(k.get_creator(), "Masa") self.assertEqual(k.get_seticon(), "img/seticon1") self.assertEqual(k.get_rarity(), "Common") # Enchantment creature def test_copy_enchantment_creature(self): self.set_card() k = EnchantmentCreature(self.card.get_name()) k.copy(self.card) self.assertEqual(k.get_id(), "1234567") self.assertEqual(k.get_name(), "Party Tutor") self.assertEqual(k.get_image(), "img/partytutor") self.assertEqual(k.get_maintype(), "Enchantment Creature") self.assertEqual(k.get_legendary(), False) self.assertEqual(k.get_tribal(), None) self.assertEqual(k.get_subtype(), ["Teekkari", "ISO"]) self.assertEqual(k.get_colour(), ["Vihreä"]) self.assertEqual(k.get_manacost(), "2U") self.assertEqual(k.get_power(), 3) self.assertEqual(k.get_toughness(), 2) self.assertEqual(k.get_feature(), ["Haste", "Trample"]) self.assertEqual(k.get_feature2(), []) self.assertEqual(k.get_ruletext(), "Party Tutor rule") self.assertEqual(k.get_flavourtext(), "Party") self.assertEqual(k.get_creator(), "Masa") self.assertEqual(k.get_seticon(), "img/seticon1") self.assertEqual(k.get_rarity(), "Common") # Instant def test_copy_instant(self): self.set_card() k = Instant(self.card.get_name()) k.copy(self.card) self.assertEqual(k.get_id(), "1234567") self.assertEqual(k.get_name(), "Party Tutor") self.assertEqual(k.get_image(), "img/partytutor") self.assertEqual(k.get_maintype(), "Instant") self.assertEqual(k.get_legendary(), False) self.assertEqual(k.get_tribal(), True) self.assertEqual(k.get_subtype(), ["Teekkari", "ISO"]) self.assertEqual(k.get_colour(), ["Vihreä"]) self.assertEqual(k.get_manacost(), "2U") self.assertEqual(k.get_power(), None) self.assertEqual(k.get_toughness(), None) self.assertEqual(k.get_feature(), None) self.assertEqual(k.get_feature2(), []) self.assertEqual(k.get_ruletext(), "Party Tutor rule") self.assertEqual(k.get_flavourtext(), "Party") self.assertEqual(k.get_creator(), "Masa") self.assertEqual(k.get_seticon(), "img/seticon1") self.assertEqual(k.get_rarity(), "Common") self.assertEqual(k.get_feature_print(), "") k.remove_feature("Haste") self.assertEqual(k.get_feature_list(), []) # Land def test_copy_land(self): self.set_card() k = Land(self.card.get_name()) k.copy(self.card) self.assertEqual(k.get_id(), "1234567") self.assertEqual(k.get_name(), "Party Tutor") self.assertEqual(k.get_image(), "img/partytutor") self.assertEqual(k.get_maintype(), "Land") self.assertEqual(k.get_legendary(), False) self.assertEqual(k.get_tribal(), None) self.assertEqual(k.get_subtype(), ["Teekkari", "ISO"]) self.assertEqual(k.get_colour(), ["Vihreä"]) self.assertEqual(k.get_manacost(), None) self.assertEqual(k.get_power(), None) self.assertEqual(k.get_toughness(), None) self.assertEqual(k.get_feature(), []) self.assertEqual(k.get_feature2(), ["Hexproof", "Indestructible"]) self.assertEqual(k.get_ruletext(), "Party Tutor rule") self.assertEqual(k.get_flavourtext(), "Party") self.assertEqual(k.get_creator(), "Masa") self.assertEqual(k.get_seticon(), "img/seticon1") self.assertEqual(k.get_rarity(), "Common") # Planeswalker def test_copy_planeswalker(self): self.set_card() k = Planeswalker(self.card.get_name()) k.copy(self.card) self.assertEqual(k.get_id(), "1234567") self.assertEqual(k.get_name(), "Party Tutor") self.assertEqual(k.get_image(), "img/partytutor") self.assertEqual(k.get_maintype(), "Planeswalker") self.assertEqual(k.get_legendary(), False) self.assertEqual(k.get_tribal(), None) self.assertEqual(k.get_subtype(), ["Teekkari", "ISO"]) self.assertEqual(k.get_colour(), ["Vihreä"]) self.assertEqual(k.get_manacost(), "2U") self.assertEqual(k.get_power(), 3) self.assertEqual(k.get_toughness(), 2) self.assertEqual(k.get_feature(), ["Haste", "Trample"]) self.assertEqual(k.get_feature2(), []) self.assertEqual(k.get_ruletext(), "Party Tutor rule") self.assertEqual(k.get_flavourtext(), "Party") self.assertEqual(k.get_creator(), "Masa") self.assertEqual(k.get_seticon(), "img/seticon1") self.assertEqual(k.get_rarity(), "Common") # Sorcery def test_copy_sorcery(self): self.set_card() k = Sorcery(self.card.get_name()) k.copy(self.card) self.assertEqual(k.get_id(), "1234567") self.assertEqual(k.get_name(), "Party Tutor") self.assertEqual(k.get_image(), "img/partytutor") self.assertEqual(k.get_maintype(), "Sorcery") self.assertEqual(k.get_legendary(), False) self.assertEqual(k.get_tribal(), True) self.assertEqual(k.get_subtype(), ["Teekkari", "ISO"]) self.assertEqual(k.get_colour(), ["Vihreä"]) self.assertEqual(k.get_manacost(), "2U") self.assertEqual(k.get_power(), None) self.assertEqual(k.get_toughness(), None) self.assertEqual(k.get_feature(), None) self.assertEqual(k.get_feature2(), []) self.assertEqual(k.get_ruletext(), "Party Tutor rule") self.assertEqual(k.get_flavourtext(), "Party") self.assertEqual(k.get_creator(), "Masa") self.assertEqual(k.get_seticon(), "img/seticon1") self.assertEqual(k.get_rarity(), "Common")
class TestCardRepository(unittest.TestCase): def setUp(self): card_repository.delete_all() self.card1 = Card('Teemu Kerppu') self.card2 = Creature('Kana') self.card3 = Instant('Kortti') self.card4 = Creature('Kana2') self.card1.set_cubes(["id1"]) self.card2.set_cubes(["id1"]) self.card3.set_cubes(["id2"]) self.card4.set_cubes(["id1"]) def test_create(self): card_repository.create(self.card1) cards = card_repository.find_all() self.assertEqual(len(cards), 1) self.assertEqual(cards[0][1], self.card1.get_name()) def test_save_create(self): card_repository.save(self.card1) cards = card_repository.find_all() self.assertEqual(len(cards), 1) self.assertEqual(cards[0][1], self.card1.get_name()) def test_save_update(self): card_repository.create(self.card1) self.card1.set_name("Korppu") card_repository.save(self.card1) cards = card_repository.find_all() self.assertEqual(len(cards), 1) self.assertEqual(cards[0][1], "Korppu") def test_delete(self): card_repository.create(self.card1) cards = card_repository.find_all() self.assertEqual(len(cards), 1) self.assertEqual(cards[0][1], "Teemu Kerppu") card_repository.delete(self.card1.get_id()) cards = card_repository.find_all() self.assertEqual(len(cards), 0) def test_delete_all(self): card_repository.create(self.card1) card_repository.create(self.card2) card_repository.create(self.card3) cards = card_repository.find_all() self.assertEqual(len(cards), 3) card_repository.delete_all() cards = card_repository.find_all() self.assertEqual(len(cards), 0) def test_find_all(self): card_repository.create(self.card1) card_repository.create(self.card2) cards = card_repository.find_all() self.assertEqual(len(cards), 2) self.assertEqual(cards[0][1], self.card1.get_name()) self.assertEqual(cards[1][1], self.card2.get_name()) def test_find_by_cube(self): card_repository.create(self.card1) card_repository.create(self.card2) card_repository.create(self.card3) cards = card_repository.find_by_cube("id1") self.assertEqual(len(cards), 2) self.assertEqual(cards[0][1], self.card1.get_name()) self.assertEqual(cards[1][1], self.card2.get_name()) def test_find_by_name_from_cube(self): card_repository.create(self.card1) card_repository.create(self.card2) card_repository.create(self.card3) cards = card_repository.find_by_name_from_cube("id1", "kana") self.assertEqual(len(cards), 1) self.assertEqual(cards[0][1], self.card2.get_name()) def test_find_cards_from_cube_that_contains(self): card_repository.create(self.card1) card_repository.create(self.card2) card_repository.create(self.card3) card_repository.create(self.card4) cards = card_repository.find_cards_from_cube_that_contains("id1", "", "Creature", "", ["name", "ASC"]) self.assertEqual(len(cards), 2) self.assertEqual(cards[0][1], self.card2.get_name()) self.assertEqual(cards[1][1], self.card4.get_name()) def test_create_csv_file(self): card_repository.create(self.card1) card_repository.create(self.card2) card_repository.create(self.card3) card_repository.create(self.card4) cursor = card_repository.create_csv_file("id1") cards = cursor.fetchall() self.assertEqual(len(cards), 3) self.assertEqual(cards[0][1], self.card1.get_name()) self.assertEqual(cards[1][1], self.card2.get_name()) self.assertEqual(cards[2][1], self.card4.get_name())
def change_card_type(self, card, maintype): """ Modifies card's maintype. (Creates a new Card subclass entity that copies the properties from the old one.) Args: card: [Card] Card entity that needs to be changed. maintype: [String] New maintype for the card. """ if maintype == "Creature": new_card = Creature(card.get_name()) elif maintype == "Artifact": new_card = Artifact(card.get_name()) elif maintype == "Enchantment": new_card = Enchantment(card.get_name()) elif maintype == "Land": new_card = Land(card.get_name()) elif maintype == "Instant": new_card = Instant(card.get_name()) elif maintype == "Sorcery": new_card = Sorcery(card.get_name()) elif maintype == "Planeswalker": new_card = Planeswalker(card.get_name()) elif maintype == "Artifact Creature": new_card = ArtifactCreature(card.get_name()) elif maintype == "Enchantment Creature": new_card = EnchantmentCreature(card.get_name()) new_card.copy(card) return new_card