Scrython/unittests/test_cards.py

285 lines
9.1 KiB
Python
Raw Normal View History

2018-10-22 17:52:23 +00:00
# This workaround makes sure that we can import from the parent dir
import sys
sys.path.append('..')
2018-10-23 04:35:26 +00:00
from scrython.cards import Id, Autocomplete, Search, Collector
2018-10-22 17:52:23 +00:00
import unittest
import time
2018-10-23 16:17:19 +00:00
# Cards for TestCardObjects
2018-10-23 04:35:26 +00:00
mtgo_card = Id(id='e3285e6b-3e79-4d7c-bf96-d920f973b122'); time.sleep(0.1)
2019-09-26 00:25:14 +00:00
non_online_card = Id(id='cfdd00f0-c6aa-4e8b-a035-fb3403711741'); time.sleep(0.1)
frame_effected_card = Id(id='f185a734-a32a-4244-88e8-dabafbfd064f'); time.sleep(0.1)
2018-10-23 04:35:26 +00:00
arena_card = Id(id='5aa75f2b-53c5-47c5-96d2-ab796358a96f'); time.sleep(0.1)
augment = Id(id='abe9fdfa-c361-465e-9639-097d441a3f74'); time.sleep(0.1)
meld = Id(id='0900e494-962d-48c6-8e78-66a489be4bb2'); time.sleep(0.1)
transform = Id(id='aae6fb12-b252-453b-bca7-1ea2a0d6c8dc'); time.sleep(0.1)
vanguard = Id(id='87c1234b-3834-4bba-bef2-05707bb1e8e2'); time.sleep(0.1)
alt_lang_card = Collector(code='ths', collector_number='75', lang='ja'); time.sleep(0.1)
planeswalker = Id(id='4c565076-5db2-47ea-8ee0-4a4fd7bb353d'); time.sleep(0.1)
2019-10-03 01:15:26 +00:00
preview_check = Id(id='fb6b12e7-bb93-4eb6-bad1-b256a6ccff4e'); time.sleep(0.1)
2021-09-06 16:02:33 +00:00
meld_card = Id(id='5a7a212e-e0b6-4f12-a95c-173cae023f93'); time.sleep(0.1)
2021-09-06 16:32:30 +00:00
foil_etched = Id(id='47f44d5a-f3d6-4a9a-8bd3-b17a88565c51'); time.sleep(0.1)
2018-10-23 04:35:26 +00:00
2018-10-23 16:17:19 +00:00
autocomplete = Autocomplete(q='Thal'); time.sleep(0.1)
search = Search(q='f:commander')
2018-10-23 04:35:26 +00:00
class TestCardObjects(unittest.TestCase):
2018-10-22 17:52:23 +00:00
def __init__(self, *args, **kwargs):
2018-10-23 04:35:26 +00:00
super(TestCardObjects, self).__init__(*args, **kwargs)
2018-10-22 17:52:23 +00:00
def test_object(self):
2018-10-23 04:35:26 +00:00
self.assertIsInstance(non_online_card.object(), str)
def test_id(self):
2018-10-23 04:35:26 +00:00
self.assertIsInstance(non_online_card.id(), str)
def test_multiverse_ids(self):
2018-10-23 04:35:26 +00:00
self.assertIsInstance(non_online_card.multiverse_ids(), list)
def test_mtgo_id(self):
2018-10-23 04:35:26 +00:00
self.assertRaises(KeyError, non_online_card.mtgo_id)
self.assertIsInstance(mtgo_card.mtgo_id(), int)
def test_mtgo_foil_id(self):
2018-10-23 04:35:26 +00:00
self.assertIsInstance(mtgo_card.mtgo_foil_id(), int)
def test_name(self):
2018-10-23 04:35:26 +00:00
self.assertIsInstance(non_online_card.name(), str)
def test_uri(self):
2018-10-23 04:35:26 +00:00
self.assertIsInstance(non_online_card.uri(), str)
def test_scryfall_uri(self):
2018-10-23 04:35:26 +00:00
self.assertIsInstance(non_online_card.scryfall_uri(), str)
def test_layout(self):
2018-10-23 04:35:26 +00:00
self.assertIsInstance(non_online_card.layout(), str)
def test_highres_image(self):
2018-10-23 04:35:26 +00:00
self.assertIsInstance(non_online_card.highres_image(), bool)
def test_image_uris(self):
2018-10-23 04:35:26 +00:00
self.assertIsInstance(non_online_card.image_uris(), dict)
2018-10-30 17:38:22 +00:00
self.assertRaises(Exception, non_online_card.image_uris, 'normal')
self.assertRaises(KeyError, non_online_card.image_uris, 0, 'foo')
def test_cmc(self):
2018-10-23 04:35:26 +00:00
self.assertIsInstance(non_online_card.cmc(), float)
def test_type_line(self):
2018-10-23 04:35:26 +00:00
self.assertIsInstance(non_online_card.type_line(), str)
def test_oracle_text(self):
2018-10-23 04:35:26 +00:00
self.assertIsInstance(non_online_card.oracle_text(), str)
def test_mana_cost(self):
2018-10-23 04:35:26 +00:00
self.assertIsInstance(non_online_card.mana_cost(), str)
def test_colors(self):
2018-10-23 04:35:26 +00:00
self.assertIsInstance(non_online_card.colors(), list)
def test_color_identity(self):
2018-10-23 04:35:26 +00:00
self.assertIsInstance(non_online_card.color_identity(), list)
def test_legalities(self):
2018-10-23 04:35:26 +00:00
self.assertIsInstance(non_online_card.legalities(), dict)
def test_reserved(self):
2018-10-23 04:35:26 +00:00
self.assertIsInstance(non_online_card.reserved(), bool)
def test_reprint(self):
2018-10-23 04:35:26 +00:00
self.assertIsInstance(non_online_card.reprint(), bool)
def test_set_code(self):
2018-10-23 04:35:26 +00:00
self.assertIsInstance(non_online_card.set_code(), str)
def test_set_name(self):
2018-10-23 04:35:26 +00:00
self.assertIsInstance(non_online_card.set_name(), str)
def test_set_uri(self):
2018-10-23 04:35:26 +00:00
self.assertIsInstance(non_online_card.set_uri(), str)
def test_set_search_uri(self):
2018-10-23 04:35:26 +00:00
self.assertIsInstance(non_online_card.set_search_uri(), str)
def test_scryfall_set_uri(self):
2018-10-23 04:35:26 +00:00
self.assertIsInstance(non_online_card.scryfall_set_uri(), str)
def test_rulings_uri(self):
2018-10-23 04:35:26 +00:00
self.assertIsInstance(non_online_card.rulings_uri(), str)
def test_prints_search_uri(self):
2018-10-23 04:35:26 +00:00
self.assertIsInstance(non_online_card.prints_search_uri(), str)
def test_collector_number(self):
2018-10-23 04:35:26 +00:00
self.assertIsInstance(non_online_card.collector_number(), str)
def test_digital(self):
2018-10-23 04:35:26 +00:00
self.assertIsInstance(non_online_card.digital(), bool)
def test_rarity(self):
2018-10-23 04:35:26 +00:00
self.assertIsInstance(non_online_card.rarity(), str)
def test_illuStringation_id(self):
2018-10-23 04:35:26 +00:00
self.assertIsInstance(non_online_card.illustration_id(), str)
def test_artist(self):
2018-10-23 04:35:26 +00:00
self.assertIsInstance(non_online_card.artist(), str)
def test_frame(self):
2018-10-23 04:35:26 +00:00
self.assertIsInstance(non_online_card.frame(), str)
def test_full_art(self):
2018-10-23 04:35:26 +00:00
self.assertIsInstance(non_online_card.full_art(), bool)
def test_border_color(self):
2018-10-23 04:35:26 +00:00
self.assertIsInstance(non_online_card.border_color(), str)
def test_edhrec_rank(self):
2018-10-23 04:35:26 +00:00
self.assertIsInstance(non_online_card.edhrec_rank(), int)
2019-04-01 18:07:55 +00:00
def test_prices(self):
self.assertIsInstance(non_online_card.prices('eur'), str)
def test_related_uris(self):
2018-10-23 04:35:26 +00:00
self.assertIsInstance(non_online_card.related_uris(), dict)
def test_purchase_uris(self):
2018-10-23 04:35:26 +00:00
self.assertIsInstance(non_online_card.purchase_uris(), dict)
def test_life_modifier(self):
2018-10-23 04:35:26 +00:00
self.assertIsInstance(vanguard.life_modifier(), str)
def test_hand_modifier(self):
2018-10-23 04:35:26 +00:00
self.assertIsInstance(vanguard.hand_modifier(), str)
def test_color_indicator(self):
2018-10-23 04:35:26 +00:00
self.assertIsInstance(transform.color_indicator(1), list)
def test_all_parts(self):
2021-09-06 16:02:33 +00:00
self.assertIsInstance(meld_card.all_parts(), list)
2018-10-22 20:40:41 +00:00
def non_online_card_faces(self):
2018-10-23 04:35:26 +00:00
self.assertIsInstance(transform.card_faces(), list)
def test_watermark(self):
2018-10-23 04:35:26 +00:00
self.assertIsInstance(mtgo_card.watermark(), str)
def test_story_spotlight(self):
2018-10-23 04:35:26 +00:00
self.assertIsInstance(non_online_card.story_spotlight(), bool)
def test_power(self):
2018-10-23 04:35:26 +00:00
self.assertIsInstance(augment.power(), str)
def test_toughness(self):
2018-10-23 04:35:26 +00:00
self.assertIsInstance(augment.toughness(), str)
def test_flavor_text(self):
2018-10-23 04:35:26 +00:00
self.assertIsInstance(meld.flavor_text(), str)
def test_arena_id(self):
2018-10-23 04:35:26 +00:00
self.assertIsInstance(arena_card.arena_id(), int)
def test_lang(self):
2018-10-23 04:35:26 +00:00
self.assertIsInstance(non_online_card.lang(), str)
def test_printed_name(self):
2018-10-23 04:35:26 +00:00
self.assertIsInstance(alt_lang_card.printed_name(), str)
def test_printed_type_line(self):
2018-10-23 04:35:26 +00:00
self.assertIsInstance(alt_lang_card.printed_type_line(), str)
def test_printed_text(self):
2018-10-23 04:35:26 +00:00
self.assertIsInstance(alt_lang_card.printed_text(), str)
def test_oracle_id(self):
2018-10-23 04:35:26 +00:00
self.assertIsInstance(non_online_card.oracle_id(), str)
def test_loyalty(self):
2018-10-23 04:35:26 +00:00
self.assertIsInstance(planeswalker.loyalty(), str)
def test_oversized(self):
2018-10-23 04:35:26 +00:00
self.assertIsInstance(non_online_card.oversized(), bool)
2018-10-22 17:52:23 +00:00
2019-10-03 01:15:26 +00:00
def test_preview(self):
self.assertIsInstance(preview_check.preview(), dict)
self.assertIsInstance(preview_check.preview('source'), str)
def test_image_status(self):
self.assertIsInstance(non_online_card.image_status(), str)
2021-09-06 16:32:30 +00:00
def test_finishes(self):
self.assertIsInstance(foil_etched.finishes(), list)
def test_tcgplayer_id(self):
self.assertIsInstance(non_online_card.tcgplayer_id(), int)
def test_tcgplayer_etched_id(self):
self.assertIsInstance(foil_etched.tcgplayer_etched_id(), int)
def test_frame_effects(self):
self.assertIsInstance(frame_effected_card.frame_effects(), list)
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)
2018-10-23 16:17:19 +00:00
class TestAutocomplete(unittest.TestCase):
def test_object(self):
self.assertIsInstance(autocomplete.object(), str)
def test_total_items(self):
self.assertIsInstance(autocomplete.total_values(), int)
def test_data(self):
self.assertIsInstance(autocomplete.data(), list)
class TestSearch(unittest.TestCase):
def test_object(self):
self.assertIsInstance(search.object(), str)
def test_total_cards(self):
self.assertIsInstance(search.total_cards(), int)
def test_data(self):
self.assertIsInstance(search.data(), list)
def test_has_more(self):
self.assertIsInstance(search.has_more(), bool)
def test_next_page(self):
self.assertIsInstance(search.next_page(), str)
def test_data_length(self):
self.assertIsInstance(search.data_length(), int)
2018-10-22 17:52:23 +00:00
if __name__ == '__main__':
2018-10-23 04:35:26 +00:00
test_classes_to_run = [
2018-10-23 16:17:19 +00:00
TestCardObjects,
TestSearch,
TestAutocomplete
2018-10-23 04:35:26 +00:00
]
loader = unittest.TestLoader()
suites_list = []
for test_class in test_classes_to_run:
suite = loader.loadTestsFromTestCase(test_class)
suites_list.append(suite)
big_suite = unittest.TestSuite(suites_list)
runner = unittest.TextTestRunner()
results = runner.run(big_suite)