Updated unittests

This commit is contained in:
NandaScott 2019-04-01 14:07:55 -04:00
parent 646ce5cdc1
commit 28ceb451ae
1 changed files with 17 additions and 177 deletions

View File

@ -28,11 +28,9 @@ class TestCardObjects(unittest.TestCase):
def test_object(self): def test_object(self):
self.assertIsInstance(non_online_card.object(), str) self.assertIsInstance(non_online_card.object(), str)
self.assertEqual(non_online_card.object(), 'card')
def test_id(self): def test_id(self):
self.assertIsInstance(non_online_card.id(), str) self.assertIsInstance(non_online_card.id(), str)
self.assertEqual(non_online_card.id(), '15016e8e-2f6b-4470-865a-ec13da3cb968')
def test_multiverse_ids(self): def test_multiverse_ids(self):
self.assertIsInstance(non_online_card.multiverse_ids(), list) self.assertIsInstance(non_online_card.multiverse_ids(), list)
@ -40,350 +38,178 @@ class TestCardObjects(unittest.TestCase):
def test_mtgo_id(self): def test_mtgo_id(self):
self.assertRaises(KeyError, non_online_card.mtgo_id) self.assertRaises(KeyError, non_online_card.mtgo_id)
self.assertIsInstance(mtgo_card.mtgo_id(), int) self.assertIsInstance(mtgo_card.mtgo_id(), int)
self.assertEqual(mtgo_card.mtgo_id(), 67196)
def test_mtgo_foil_id(self): def test_mtgo_foil_id(self):
self.assertIsInstance(mtgo_card.mtgo_foil_id(), int) self.assertIsInstance(mtgo_card.mtgo_foil_id(), int)
self.assertEqual(mtgo_card.mtgo_foil_id(), 67197)
def test_name(self): def test_name(self):
self.assertIsInstance(non_online_card.name(), str) self.assertIsInstance(non_online_card.name(), str)
self.assertEqual(non_online_card.name(), 'Magical Hack')
def test_uri(self): def test_uri(self):
self.assertIsInstance(non_online_card.uri(), str) self.assertIsInstance(non_online_card.uri(), str)
self.assertEqual(non_online_card.uri(), 'https://api.scryfall.com/cards/15016e8e-2f6b-4470-865a-ec13da3cb968')
def test_scryfall_uri(self): def test_scryfall_uri(self):
self.assertIsInstance(non_online_card.scryfall_uri(), str) self.assertIsInstance(non_online_card.scryfall_uri(), str)
self.assertEqual(non_online_card.scryfall_uri(), 'https://scryfall.com/card/ced/64/magical-hack?utm_source=api')
def test_layout(self): def test_layout(self):
self.assertIsInstance(non_online_card.layout(), str) self.assertIsInstance(non_online_card.layout(), str)
self.assertEqual(non_online_card.layout(), 'normal')
def test_highres_image(self): def test_highres_image(self):
self.assertIsInstance(non_online_card.highres_image(), bool) self.assertIsInstance(non_online_card.highres_image(), bool)
self.assertEqual(non_online_card.highres_image(), True)
def test_image_uris(self): def test_image_uris(self):
self.assertIsInstance(non_online_card.image_uris(), dict) self.assertIsInstance(non_online_card.image_uris(), dict)
self.assertEqual(non_online_card.image_uris(), {
"small": "https://img.scryfall.com/cards/small/en/ced/64.jpg?1517813031",
"normal": "https://img.scryfall.com/cards/normal/en/ced/64.jpg?1517813031",
"large": "https://img.scryfall.com/cards/large/en/ced/64.jpg?1517813031",
"png": "https://img.scryfall.com/cards/png/en/ced/64.png?1517813031",
"art_crop": "https://img.scryfall.com/cards/art_crop/en/ced/64.jpg?1517813031",
"border_crop": "https://img.scryfall.com/cards/border_crop/en/ced/64.jpg?1517813031"
})
self.assertEqual(non_online_card.image_uris(0, 'normal'), 'https://img.scryfall.com/cards/normal/en/ced/64.jpg?1517813031')
self.assertRaises(Exception, non_online_card.image_uris, 'normal') self.assertRaises(Exception, non_online_card.image_uris, 'normal')
self.assertRaises(KeyError, non_online_card.image_uris, 0, 'foo') self.assertRaises(KeyError, non_online_card.image_uris, 0, 'foo')
def test_cmc(self): def test_cmc(self):
self.assertIsInstance(non_online_card.cmc(), float) self.assertIsInstance(non_online_card.cmc(), float)
self.assertEqual(non_online_card.cmc(), 1.0)
def test_type_line(self): def test_type_line(self):
self.assertIsInstance(non_online_card.type_line(), str) self.assertIsInstance(non_online_card.type_line(), str)
self.assertEqual(non_online_card.type_line(), 'Instant')
def test_oracle_text(self): def test_oracle_text(self):
self.assertIsInstance(non_online_card.oracle_text(), str) self.assertIsInstance(non_online_card.oracle_text(), str)
self.assertEqual(non_online_card.oracle_text(), 'Change the text of target spell or permanent by replacing all instances of one basic land type with another. (For example, you may change \"swampwalk\" to \"plainswalk.\" This effect lasts indefinitely.)')
def test_mana_cost(self): def test_mana_cost(self):
self.assertIsInstance(non_online_card.mana_cost(), str) self.assertIsInstance(non_online_card.mana_cost(), str)
self.assertEqual(non_online_card.mana_cost(), '{U}')
def test_colors(self): def test_colors(self):
self.assertIsInstance(non_online_card.colors(), list) self.assertIsInstance(non_online_card.colors(), list)
self.assertEqual(non_online_card.colors(), [
"U"
])
def test_color_identity(self): def test_color_identity(self):
self.assertIsInstance(non_online_card.color_identity(), list) self.assertIsInstance(non_online_card.color_identity(), list)
self.assertEqual(non_online_card.color_identity(), [
"U"
])
def test_legalities(self): def test_legalities(self):
self.assertIsInstance(non_online_card.legalities(), dict) self.assertIsInstance(non_online_card.legalities(), dict)
self.assertEqual(non_online_card.legalities(), {
"standard": "not_legal",
"future": "not_legal",
"frontier": "not_legal",
"modern": "not_legal",
"legacy": "legal",
"pauper": "not_legal",
"vintage": "legal",
"penny": "not_legal",
"commander": "legal",
"1v1": "not_legal",
"duel": "legal",
"brawl": "not_legal"
})
def test_reserved(self): def test_reserved(self):
self.assertIsInstance(non_online_card.reserved(), bool) self.assertIsInstance(non_online_card.reserved(), bool)
self.assertEqual(non_online_card.reserved(), False)
def test_reprint(self): def test_reprint(self):
self.assertIsInstance(non_online_card.reprint(), bool) self.assertIsInstance(non_online_card.reprint(), bool)
self.assertEqual(non_online_card.reprint(), True)
def test_set_code(self): def test_set_code(self):
self.assertIsInstance(non_online_card.set_code(), str) self.assertIsInstance(non_online_card.set_code(), str)
self.assertEqual(non_online_card.set_code(), 'ced')
def test_set_name(self): def test_set_name(self):
self.assertIsInstance(non_online_card.set_name(), str) self.assertIsInstance(non_online_card.set_name(), str)
self.assertEqual(non_online_card.set_name(), 'Collectors\u2019 Edition')
def test_set_uri(self): def test_set_uri(self):
self.assertIsInstance(non_online_card.set_uri(), str) self.assertIsInstance(non_online_card.set_uri(), str)
self.assertEqual(non_online_card.set_uri(), 'https://api.scryfall.com/sets/ced')
def test_set_search_uri(self): def test_set_search_uri(self):
self.assertIsInstance(non_online_card.set_search_uri(), str) self.assertIsInstance(non_online_card.set_search_uri(), str)
self.assertEqual(non_online_card.set_search_uri(), 'https://api.scryfall.com/cards/search?order=set&q=e%3Aced&unique=prints')
def test_scryfall_set_uri(self): def test_scryfall_set_uri(self):
self.assertIsInstance(non_online_card.scryfall_set_uri(), str) self.assertIsInstance(non_online_card.scryfall_set_uri(), str)
self.assertEqual(non_online_card.scryfall_set_uri(), 'https://scryfall.com/sets/ced?utm_source=api')
def test_rulings_uri(self): def test_rulings_uri(self):
self.assertIsInstance(non_online_card.rulings_uri(), str) self.assertIsInstance(non_online_card.rulings_uri(), str)
self.assertEqual(non_online_card.rulings_uri(), 'https://api.scryfall.com/cards/15016e8e-2f6b-4470-865a-ec13da3cb968/rulings')
def test_prints_search_uri(self): def test_prints_search_uri(self):
self.assertIsInstance(non_online_card.prints_search_uri(), str) self.assertIsInstance(non_online_card.prints_search_uri(), str)
self.assertEqual(non_online_card.prints_search_uri(), 'https://api.scryfall.com/cards/search?order=set&q=%21%E2%80%9CMagical+Hack%E2%80%9D+include%3Aextras&unique=prints')
def test_collector_number(self): def test_collector_number(self):
self.assertIsInstance(non_online_card.collector_number(), str) self.assertIsInstance(non_online_card.collector_number(), str)
self.assertEqual(non_online_card.collector_number(), '64')
def test_digital(self): def test_digital(self):
self.assertIsInstance(non_online_card.digital(), bool) self.assertIsInstance(non_online_card.digital(), bool)
self.assertEqual(non_online_card.digital(), False)
def test_rarity(self): def test_rarity(self):
self.assertIsInstance(non_online_card.rarity(), str) self.assertIsInstance(non_online_card.rarity(), str)
self.assertEqual(non_online_card.rarity(), 'rare')
def test_illuStringation_id(self): def test_illuStringation_id(self):
self.assertIsInstance(non_online_card.illustration_id(), str) self.assertIsInstance(non_online_card.illustration_id(), str)
self.assertEqual(non_online_card.illustration_id(), 'ac51706f-d485-4d91-822f-bdf9eca67a48')
def test_artist(self): def test_artist(self):
self.assertIsInstance(non_online_card.artist(), str) self.assertIsInstance(non_online_card.artist(), str)
self.assertEqual(non_online_card.artist(), 'Julie Baroh')
def test_frame(self): def test_frame(self):
self.assertIsInstance(non_online_card.frame(), str) self.assertIsInstance(non_online_card.frame(), str)
self.assertEqual(non_online_card.frame(), '1993')
def test_full_art(self): def test_full_art(self):
self.assertIsInstance(non_online_card.full_art(), bool) self.assertIsInstance(non_online_card.full_art(), bool)
self.assertEqual(non_online_card.full_art(), False)
def test_border_color(self): def test_border_color(self):
self.assertIsInstance(non_online_card.border_color(), str) self.assertIsInstance(non_online_card.border_color(), str)
self.assertEqual(non_online_card.border_color(), 'black')
def test_timeshifted(self):
self.assertIsInstance(non_online_card.timeshifted(), bool)
self.assertEqual(non_online_card.timeshifted(), False)
def test_colorshifted(self):
self.assertIsInstance(non_online_card.colorshifted(), bool)
self.assertEqual(non_online_card.colorshifted(), False)
def test_futureshifted(self):
self.assertIsInstance(non_online_card.futureshifted(), bool)
self.assertEqual(non_online_card.futureshifted(), False)
def test_edhrec_rank(self): def test_edhrec_rank(self):
self.assertIsInstance(non_online_card.edhrec_rank(), int) self.assertIsInstance(non_online_card.edhrec_rank(), int)
def test_currency(self): def test_prices(self):
self.assertIsInstance(non_online_card.currency('eur'), str) self.assertIsInstance(non_online_card.prices('eur'), str)
def test_related_uris(self): def test_related_uris(self):
self.assertIsInstance(non_online_card.related_uris(), dict) self.assertIsInstance(non_online_card.related_uris(), dict)
self.assertEqual(non_online_card.related_uris(), {
"tcgplayer_decks": "http://decks.tcgplayer.com/magic/deck/search?contains=Magical+Hack&page=1&partner=Scryfall",
"edhrec": "http://edhrec.com/route/?cc=Magical+Hack",
"mtgtop8": "http://mtgtop8.com/search?MD_check=1&SB_check=1&cards=Magical+Hack"
})
def test_purchase_uris(self): def test_purchase_uris(self):
self.assertIsInstance(non_online_card.purchase_uris(), dict) self.assertIsInstance(non_online_card.purchase_uris(), dict)
self.assertEqual(non_online_card.purchase_uris(), {
"amazon": "https://www.amazon.com/gp/search?ie=UTF8&index=toys-and-games&keywords=Magical+Hack&tag=scryfall-20",
"ebay": "http://rover.ebay.com/rover/1/711-53200-19255-0/1?campid=5337966903&icep_catId=19107&icep_ff3=10&icep_sortBy=12&icep_uq=Magical+Hack&icep_vectorid=229466&ipn=psmain&kw=lg&kwid=902099&mtid=824&pub=5575230669&toolid=10001",
"tcgplayer": "https://scryfall.com/s/tcgplayer/97547",
"magiccardmarket": "https://scryfall.com/s/mcm/17013",
"cardhoarder": "https://www.cardhoarder.com/cards?affiliate_id=scryfall&data%5Bsearch%5D=Magical+Hack&ref=card-profile&utm_campaign=affiliate&utm_medium=card&utm_source=scryfall",
"card_kingdom": "https://www.cardkingdom.com/catalog/search?filter%5Bname%5D=Magical+Hack&partner=scryfall&utm_campaign=affiliate&utm_medium=scryfall&utm_source=scryfall",
"mtgo_traders": "http://www.mtgotraders.com/store/search.php?q=Magical+Hack&referral=scryfall",
"coolstuffinc": "https://scryfall.com/s/coolstuffinc/1677222"
})
def test_life_modifier(self): def test_life_modifier(self):
self.assertIsInstance(vanguard.life_modifier(), str) self.assertIsInstance(vanguard.life_modifier(), str)
self.assertEqual(vanguard.life_modifier(), '+18')
def test_hand_modifier(self): def test_hand_modifier(self):
self.assertIsInstance(vanguard.hand_modifier(), str) self.assertIsInstance(vanguard.hand_modifier(), str)
self.assertEqual(vanguard.hand_modifier(), '-2')
def test_color_indicator(self): def test_color_indicator(self):
self.assertIsInstance(transform.color_indicator(1), list) self.assertIsInstance(transform.color_indicator(1), list)
self.assertEqual(transform.color_indicator(1), [
"G",
"R"
])
def test_all_parts(self): def test_all_parts(self):
self.assertIsInstance(transform.all_parts(), list) self.assertIsInstance(transform.all_parts(), list)
self.assertEqual(transform.all_parts(), [
{
"object": "related_card",
"id": "aae6fb12-b252-453b-bca7-1ea2a0d6c8dc",
"name": "Huntmaster of the Fells // Ravager of the Fells",
"uri": "https://api.scryfall.com/cards/dka/140"
},
{
"object": "related_card",
"id": "a53f8031-aaa8-424c-929a-5478538a8cc6",
"name": "Wolf",
"uri": "https://api.scryfall.com/cards/tisd/12"
}
])
def non_online_card_faces(self): def non_online_card_faces(self):
self.assertIsInstance(transform.card_faces(), list) self.assertIsInstance(transform.card_faces(), list)
self.assertEqual(transform.card_faces(), [
{
"object": "card_face",
"name": "Huntmaster of the Fells",
"mana_cost": "{2}{R}{G}",
"type_line": "Creature \u2014 Human Werewolf",
"oracle_text": "Whenever this creature enters the battlefield or transforms into Huntmaster of the Fells, create a 2/2 green Wolf creature token and you gain 2 life.\nAt the beginning of each upkeep, if no spells were cast last turn, transform Huntmaster of the Fells.",
"colors": [
"G",
"R"
],
"power": "2",
"toughness": "2",
"artist": "Chris Rahn",
"illustration_id": "8ce1bfa2-7cd6-4f4f-b23e-c5d985acec48",
"image_uris": {
"small": "https://img.scryfall.com/cards/small/en/dka/140a.jpg?1518205189",
"normal": "https://img.scryfall.com/cards/normal/en/dka/140a.jpg?1518205189",
"large": "https://img.scryfall.com/cards/large/en/dka/140a.jpg?1518205189",
"png": "https://img.scryfall.com/cards/png/en/dka/140a.png?1518205189",
"art_crop": "https://img.scryfall.com/cards/art_crop/en/dka/140a.jpg?1518205189",
"border_crop": "https://img.scryfall.com/cards/border_crop/en/dka/140a.jpg?1518205189"
}
},
{
"object": "card_face",
"name": "Ravager of the Fells",
"mana_cost": "",
"type_line": "Creature \u2014 Werewolf",
"oracle_text": "Trample\nWhenever this creature transforms into Ravager of the Fells, it deals 2 damage to target opponent or planeswalker and 2 damage to up to one target creature that player or that planeswalker's controller controls.\nAt the beginning of each upkeep, if a player cast two or more spells last turn, transform Ravager of the Fells.",
"colors": [
"G",
"R"
],
"color_indicator": [
"G",
"R"
],
"power": "4",
"toughness": "4",
"artist": "Chris Rahn",
"illustration_id": "a26de848-cc6a-4f49-9d43-72afa3c80b3e",
"image_uris": {
"small": "https://img.scryfall.com/cards/small/en/dka/140b.jpg?1518205189",
"normal": "https://img.scryfall.com/cards/normal/en/dka/140b.jpg?1518205189",
"large": "https://img.scryfall.com/cards/large/en/dka/140b.jpg?1518205189",
"png": "https://img.scryfall.com/cards/png/en/dka/140b.png?1518205189",
"art_crop": "https://img.scryfall.com/cards/art_crop/en/dka/140b.jpg?1518205189",
"border_crop": "https://img.scryfall.com/cards/border_crop/en/dka/140b.jpg?1518205189"
}
}
])
def test_watermark(self): def test_watermark(self):
self.assertIsInstance(mtgo_card.watermark(), str) self.assertIsInstance(mtgo_card.watermark(), str)
self.assertEqual(mtgo_card.watermark(), 'set')
def test_story_spotlight(self): def test_story_spotlight(self):
self.assertIsInstance(non_online_card.story_spotlight(), bool) self.assertIsInstance(non_online_card.story_spotlight(), bool)
self.assertEqual(non_online_card.story_spotlight(), False)
def test_power(self): def test_power(self):
self.assertIsInstance(augment.power(), str) self.assertIsInstance(augment.power(), str)
self.assertEqual(augment.power(), '+4')
def test_toughness(self): def test_toughness(self):
self.assertIsInstance(augment.toughness(), str) self.assertIsInstance(augment.toughness(), str)
self.assertEqual(augment.toughness(), '+4')
def test_flavor_text(self): def test_flavor_text(self):
self.assertIsInstance(meld.flavor_text(), str) self.assertIsInstance(meld.flavor_text(), str)
self.assertEqual(meld.flavor_text(), "\"We're ready for anything!\"")
def test_arena_id(self): def test_arena_id(self):
self.assertIsInstance(arena_card.arena_id(), int) self.assertIsInstance(arena_card.arena_id(), int)
self.assertEqual(arena_card.arena_id(), 66975)
def test_lang(self): def test_lang(self):
self.assertIsInstance(non_online_card.lang(), str) self.assertIsInstance(non_online_card.lang(), str)
self.assertEqual(non_online_card.lang(), 'en')
def test_printed_name(self): def test_printed_name(self):
self.assertIsInstance(alt_lang_card.printed_name(), str) self.assertIsInstance(alt_lang_card.printed_name(), str)
self.assertEqual(alt_lang_card.printed_name(), '忌まわしき首領')
def test_printed_type_line(self): def test_printed_type_line(self):
self.assertIsInstance(alt_lang_card.printed_type_line(), str) self.assertIsInstance(alt_lang_card.printed_type_line(), str)
self.assertEqual(alt_lang_card.printed_type_line(), 'クリーチャー — デーモン')
def test_printed_text(self): def test_printed_text(self):
self.assertIsInstance(alt_lang_card.printed_text(), str) self.assertIsInstance(alt_lang_card.printed_text(), str)
self.assertEqual(alt_lang_card.printed_text(), '飛行\n忌まわしき首領が戦場に出たとき、飛行を持つ黒の1/1のハーピー・クリーチャー・トークンをあなたの黒への信心に等しい数だけ戦場に出す。(あなたの黒への信心は、あなたがコントロールするパーマネントのマナ・コストに含まれる{B}の総数に等しい。)\nあなたのアップキープの開始時に、クリーチャーを1体生け贄に捧げる。')
def test_oracle_id(self): def test_oracle_id(self):
self.assertIsInstance(non_online_card.oracle_id(), str) self.assertIsInstance(non_online_card.oracle_id(), str)
self.assertEqual(non_online_card.oracle_id(), 'cba229fa-9035-405b-b091-3798898a37ee')
def test_foil(self): def test_foil(self):
self.assertIsInstance(non_online_card.foil(), bool) self.assertIsInstance(non_online_card.foil(), bool)
self.assertEqual(non_online_card.foil(), False)
def test_loyalty(self): def test_loyalty(self):
self.assertIsInstance(planeswalker.loyalty(), str) self.assertIsInstance(planeswalker.loyalty(), str)
self.assertEqual(planeswalker.loyalty(), '4')
def test_non_foil(self): def test_non_foil(self):
self.assertIsInstance(non_online_card.nonfoil(), bool) self.assertIsInstance(non_online_card.nonfoil(), bool)
self.assertEqual(non_online_card.nonfoil(), True)
def test_oversized(self): def test_oversized(self):
self.assertIsInstance(non_online_card.oversized(), bool) self.assertIsInstance(non_online_card.oversized(), bool)
self.assertEqual(non_online_card.oversized(), False)
class TestAutocomplete(unittest.TestCase): class TestAutocomplete(unittest.TestCase):
def test_object(self): def test_object(self):
self.assertIsInstance(autocomplete.object(), str) self.assertIsInstance(autocomplete.object(), str)
self.assertEqual(autocomplete.object(), 'catalog')
def test_total_items(self): def test_total_items(self):
self.assertIsInstance(autocomplete.total_values(), int) self.assertIsInstance(autocomplete.total_values(), int)
@ -395,7 +221,6 @@ class TestSearch(unittest.TestCase):
def test_object(self): def test_object(self):
self.assertIsInstance(search.object(), str) self.assertIsInstance(search.object(), str)
self.assertEqual(search.object(), 'list')
def test_total_cards(self): def test_total_cards(self):
self.assertIsInstance(search.total_cards(), int) self.assertIsInstance(search.total_cards(), int)
@ -412,6 +237,21 @@ class TestSearch(unittest.TestCase):
def test_data_length(self): def test_data_length(self):
self.assertIsInstance(search.data_length(), int) self.assertIsInstance(search.data_length(), int)
def test_tcgplayer_id(self):
self.assertIsInstance(non_online_card.tcgplayer_id(), int)
def test_frame_effect(self):
self.assertIsInstance(transform.frame_effect(), str)
def test_games(self):
self.assertIsInstance(non_online_card.games(), list)
def test_promo(self):
self.assertIsInstance(non_online_card.promo(), bool)
def test_released_at(self):
self.assertIsInstance(non_online_card.released_at(), str)
if __name__ == '__main__': if __name__ == '__main__':
test_classes_to_run = [ test_classes_to_run = [