def start(self): # Cache set & card data for set_name in self.scraper.get_sets(): # Instantiate set models set = Set(set_name) # Check if set exists, otherwise cache it if not self.has_set(set_name): self.cache['sets'][set_name] = {} self.cache_set_images(set) for card_url in self.scraper.get_card_urls(set.get_name()): card_name = self.scraper.get_card_name(card_url) new_card = True # Check if card exists, otherwise cache it if not self.has_card(set.get_name(), card_name): self.cache['sets'][set.get_name()][self.scraper.get_card_name(card_url)] = self.scraper.get_card(set.get_name(), card_url) if not self.config['silent']: print(colored('[CACHED][CARD] ' + self.scraper.get_card_name(card_name), 'blue')) else: new_card = False if not self.config['silent']: print(colored('[FROM CACHE][CARD] ' + self.scraper.get_card_name(card_name), 'yellow')) # Instantiate card model card = Card(self.cache['sets'][set.get_name()][card_name], new=new_card) set.append_card(card) self.cache_card_images(card) self.spoiler.append_set(set)
def test_lesson_card_creation(self): with self.app.app_context(): # Please change lesson_id to an existing Lesson in your db lesson_text = """ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut eu nunc id ante pharetra viverra vel et lectus. Etiam finibus massa sit amet lectus sollicitudin cursus. Aliquam erat volutpat. Vivamus aliquam elit nec augue vulputate consequat vel euismod tellus. Suspendisse potenti. Proin non felis in mauris tincidunt consequat et non enim. Mauris fermentum, odio a fringilla condimentum, massa orci ornare elit, vel pellentesque sapien tellus at nunc. Vivamus ultrices at tortor et imperdiet. Integer malesuada dolor lectus, quis fringilla ligula pulvinar a. Cras dignissim hendrerit felis, eu gravida urna rhoncus eu. Ut mauris sem, ultrices a efficitur at, pellentesque ac dolor.""" # Adds a card to database new_card = Card(lesson_id=self.lesson_id, text=lesson_text.encode("utf-8")) self.assertTrue(new_card.save_to_db())
def create_cards(number_of_cards, creator_id): for i in range(number_of_cards): card = Card(name=f"card_{i+1}", card_type='white', created_by=creator_id) db.session.add(card) db.session.commit()
def create_card(self, card_name, card_type): card = Card(name=card_name, card_type=card_type, created_by=None) db.session.add(card) db.session.commit() association = CardAssociation(card_id=card.id, collection_id=self.id) db.session.add(association) db.session.commit()
def create(self, args): """ Create new card. :param args: New card validated information :return: New card data """ # Create new card args['owner_id'] = current_user.id card = Card(**args) card.save() db.session.commit() # Respond with new card data card_schema = CardSchema() return json_response(code=201, message='Successfully created a new card.', data=[card_schema.dump(card).data])
def create_deck(folder_path, collection_name): white_cards = [] black_cards = [] white_cards_path = f"./decks/{folder_path}/white_cards.csv" black_cards_path = f"./decks/{folder_path}/black_cards.csv" new_collection = Collection(name=collection_name, editable=False) db.session.add(new_collection) db.session.commit() with open(white_cards_path) as csv_file: white_cards_reader = csv.reader(csv_file, delimiter=';') for row in white_cards_reader: new_card = Card(name=row[1], card_type='white', created_by=None) db.session.add(new_card) db.session.commit() new_association = CardAssociation(card_id=new_card.id, collection_id=new_collection.id) db.session.add(new_association) db.session.commit() with open(black_cards_path) as csv_file: black_cards_reader = csv.reader(csv_file, delimiter=';') for row in black_cards_reader: new_card = Card(name=row[1], card_type='black') db.session.add(new_card) db.session.commit() new_association = CardAssociation(card_id=new_card.id, collection_id=new_collection.id) db.session.add(new_association) db.session.commit()
def setUp(self): self.card = Card({ 'name': 'Keldon Warcaller', 'manacost': '5GBR', 'type': 'Legendary Creature', 'sub_types': ['Elemental'], 'set': 'dom', 'rules_text': 'Creatures you control have haste. Cascade, cascade (When you cast this spell, exile cards from the top of your library until you exile a nonland card that costs less. You may cast it without paying its mana cost. Put the exiled cards on the bottom of your library in a random order. Then do it again.)', 'flavor': 'Test flavor', 'artist': 'Thomas M. Baxa', 'power': '7', 'toughness': '5', 'url': 'http://mythicspoiler.com/dom/cards/keldonwarcaller.html', })
def create_card(user): body = request.get_json() if (body['name'] and body['card_type']): new_card = Card(name=body['name'], card_type=body['card_type'], created_by=user.id) db.session.add(new_card) db.session.commit() default_collection_id = Collection.query.filter_by( created_by=user.id, name='Minhas cartas').first().id # Add card to default collection, mandatory new_association = CardAssociation(card_id=new_card.id, collection_id=default_collection_id) db.session.add(new_association) db.session.commit() # Add card to another collection, the one in which it was created if (body['collection_id'] != default_collection_id): optional_association = CardAssociation( card_id=new_card.id, collection_id=body['collection_id']) db.session.add(optional_association) db.session.commit() card_response = card_share_schema.dump(new_card) card_response['collections'] = collections_share_schema.dump( new_card.collections) res = {'message': 'Card created', 'card': card_response} return jsonify(res) else: res = {'message': 'Missing attributes'} return jsonify(res), 422
def test_find_existing_card(self): # Arrange self.set.append_card( Card({ 'name': 'test-card-name', 'manacost': None, 'type': None, 'sub_types': None, 'set': None, 'rules_text': None, 'flavor': None, 'artist': None, 'power': None, 'toughness': None, 'url': None, })) # Act result = self.set.find_card('test-card-name') # Assert self.assertEquals(result.get_name(), 'test-card-name') self.assertIsInstance(result, Card)
def run(self): """ Run CardsSeeder actions. """ # Drop all collections db.session.query(Card).delete() # Generate users id list users = User.query.all() user_ids = list(map(lambda user: user.id, users)) # Generate fake data faker = Faker() for card in range(60): card = Card( **{ 'owner_id': random.choice(user_ids), 'title': faker.sentence(), 'note': faker.paragraph(nb_sentences=2), }) db.session.add(card) # Commit db session db.session.commit() # Generate parent cards id list cards = Card.query.all() card_ids = list(map(lambda i: cards[i].id, range(10))) # Assign parent card id for j in range(10, 60): cards[j].parent_card_id = random.choice(card_ids) # Commit db session db.session.commit()
import sys from app.models.card import Card from app.models.set import Set import inspect AdantoVanguard = Card("adanto_vanguard", "Adanto Vanguard", ['1', 'W'], ['W'], "Creature", "Vampire Soldier", "XLN", "Uncommon", 1, 65961) AshesoftheAbhorrent = Card("ashes_of_the_abhorrent", "Ashes of the Abhorrent", ['1', 'W'], ['W'], "Enchantment", "", "XLN", "Rare", 2, 65963) AxisofMortality = Card("axis_of_mortality", "Axis of Mortality", ['4', 'W', 'W'], ['W'], "Enchantment", "", "XLN", "Mythic Rare", 3, 65965) BellowingAegisaur = Card("bellowing_aegisaur", "Bellowing Aegisaur", ['5', 'W'], ['W'], "Creature", "Dinosaur", "XLN", "Uncommon", 4, 65967) BishopofRebirth = Card("bishop_of_rebirth", "Bishop of Rebirth", ['3', 'W', 'W'], ['W'], "Creature", "Vampire Cleric", "XLN", "Rare", 5, 65969) BishopsSoldier = Card("bishops_soldier", "Bishop's Soldier", ['1', 'W'], ['W'], "Creature", "Vampire Soldier", "XLN", "Common", 6, 65971) BrightReprisal = Card("bright_reprisal", "Bright Reprisal", ['4', 'W'], ['W'], "Instant", "", "XLN", "Uncommon", 7, 65973) Demystify = Card("demystify", "Demystify", ['W'], ['W'], "Instant", "", "XLN", "Common", 8, 65975) DuskborneSkymarcher = Card("duskborne_skymarcher", "Duskborne Skymarcher", ['W'], ['W'], "Creature", "Vampire Cleric", "XLN", "Uncommon", 9, 65977) EmissaryofSunrise = Card("emissary_of_sunrise", "Emissary of Sunrise", ['2', 'W'], ['W'], "Creature", "Human Cleric", "XLN",
def setUpClass(cls): cls.card = Card('test_name')
import sys from app.models.card import Card from app.models.set import Set import inspect BafflingEnd = Card("baffling_end", "Baffling End", ['1', 'W'], ['W'], "Enchantment", "", "RIX", 1, 66619) BishopofBinding = Card("bishop_of_binding", "Bishop of Binding", ['3', 'W'], ['W'], "Creature", "Vampire Cleric", "RIX", 2, 66621) BlazingHope = Card("blazing_hope", "Blazing Hope", ['W'], ['W'], "Instant", "", "RIX", 3, 66623) CleansingRay = Card("cleansing_ray", "Cleansing Ray", ['1', 'W'], ['W'], "Sorcery", "", "RIX", 4, 66625) DivineVerdict = Card("divine_verdict", "Divine Verdict", ['3', 'W'], ['W'], "Instant", "", "RIX", 5, 66627) EverdawnChampion = Card("everdawn_champion", "Everdawn Champion", ['1', 'W', 'W'], ['W'], "Creature", "Human Soldier", "RIX", 6, 66629) ExultantSkymarcher = Card("exultant_skymarcher", "Exultant Skymarcher", ['1', 'W', 'W'], ['W'], "Creature", "Vampire Soldier", "RIX", 7, 66631) FamishedPaladin = Card("famished_paladin", "Famished Paladin", ['1', 'W'], ['W'], "Creature", "Vampire Knight", "RIX", 8, 66633) ForerunneroftheLegion = Card("forerunner_of_the_legion", "Forerunner of the Legion", ['2', 'W'], ['W'], "Creature", "Vampire Knight", "RIX", 9, 66635) ImperialCeratops = Card("imperial_ceratops", "Imperial Ceratops", ['4', 'W'], ['W'], "Creature", "Dinosaur", "RIX", 10, 66637) LegionConquistador = Card("legion_conquistador", "Legion Conquistador", ['2', 'W'], ['W'], "Creature", "Vampire Soldier", "RIX", 11, 66639) LuminousBonds = Card("luminous_bonds", "Luminous Bonds", ['2', 'W'], ['W'], "Enchantment", "Aura", "RIX", 12, 66641) MajesticHeliopterus = Card("majestic_heliopterus", "Majestic Heliopterus", ['3', 'W'], ['W'], "Creature", "Dinosaur", "RIX", 13, 66643) MartyrofDusk = Card("martyr_of_dusk", "Martyr of Dusk", ['1', 'W'], ['W'], "Creature", "Vampire Soldier", "RIX", 14, 66645) MomentofTriumph = Card("moment_of_triumph", "Moment of Triumph", ['W'], ['W'], "Instant", "", "RIX", 15, 66647) PaladinofAtonement = Card("paladin_of_atonement", "Paladin of Atonement", ['1', 'W'], ['W'], "Creature", "Vampire Knight", "RIX", 16, 66649) PrideofConquerors = Card("pride_of_conquerors", "Pride of Conquerors", ['1', 'W'], ['W'], "Instant", "", "RIX", 17, 66651) RadiantDestiny = Card("radiant_destiny", "Radiant Destiny", ['2', 'W'], ['W'], "Enchantment", "", "RIX", 18, 66653) RaptorCompanion = Card("raptor_companion", "Raptor Companion", ['1', 'W'], ['W'], "Creature", "Dinosaur", "RIX", 19, 66655) SanguineGlorifier = Card("sanguine_glorifier", "Sanguine Glorifier", ['3', 'W'], ['W'], "Creature", "Vampire Cleric", "RIX", 20, 66657) SkymarcherAspirant = Card("skymarcher_aspirant", "Skymarcher Aspirant", ['W'], ['W'], "Creature", "Vampire Soldier", "RIX", 21, 66659) SlaughtertheStrong = Card("slaughter_the_strong", "Slaughter the Strong", ['1', 'W', 'W'], ['W'], "Sorcery", "", "RIX", 22, 66661) SnubhornSentry = Card("snubhorn_sentry", "Snubhorn Sentry", ['W'], ['W'], "Creature", "Dinosaur", "RIX", 23, 66663) SphinxsDecree = Card("sphinxs_decree", "Sphinx's Decree", ['1', 'W'], ['W'], "Sorcery", "", "RIX", 24, 66665)
import sys from app.models.card import Card from app.models.set import Set import inspect DivineVerdict = Card("divine_verdict", "Divine Verdict", ['3', 'W'], ['W'], "Instant", "", "W17", "Common", 1, 68414) GlorySeeker = Card("glory_seeker", "Glory Seeker", ['1', 'W'], ['W'], "Creature", "Human Soldier", "W17", "Common", 2, 68415) SerraAngel = Card("serra_angel", "Serra Angel", ['3', 'W', 'W'], ['W'], "Creature", "Angel", "W17", "Uncommon", 3, 68416) StandingTroops = Card("standing_troops", "Standing Troops", ['2', 'W'], ['W'], "Creature", "Human Soldier", "W17", "Common", 4, 68417) StormfrontPegasus = Card("stormfront_pegasus", "Stormfront Pegasus", ['1', 'W'], ['W'], "Creature", "Pegasus", "W17", "Uncommon", 5, 68418) VictorysHerald = Card("victorys_herald", "Victory's Herald", ['3', 'W', 'W', 'W'], ['W'], "Creature", "Angel", "W17", "Rare", 6, 68419) AirElemental = Card("air_elemental", "Air Elemental", ['3', 'U', 'U'], ['U'], "Creature", "Elemental", "W17", "Uncommon", 7, 68420) CoralMerfolk = Card("coral_merfolk", "Coral Merfolk", ['1', 'U'], ['U'], "Creature", "Merfolk", "W17", "Common", 8, 68421) DragUnder = Card("drag_under", "Drag Under", ['2', 'U'], ['U'], "Sorcery", "", "W17", "Common", 9, 68422) Inspiration = Card("inspiration", "Inspiration", ['3', 'U'], ['U'], "Instant", "", "W17", "Common", 10, 68423) SleepParalysis = Card("sleep_paralysis", "Sleep Paralysis", ['3', 'U'], ['U'], "Enchantment", "Aura", "W17", "Common", 11, 68424) SphinxofMagosi = Card("sphinx_of_magosi", "Sphinx of Magosi", ['3', 'U', 'U', 'U'], ['U'], "Creature", "Sphinx", "W17",
import sys from app.models.card import Card from app.models.set import Set import inspect ActofHeroism = Card("act_of_heroism", "Act of Heroism", ['1', 'W'], ['W'], "Instant", "", "HOU", "Common", 1, 65479) AdornedPouncer = Card("adorned_pouncer", "Adorned Pouncer", ['1', 'W'], ['W'], "Creature", "Cat", "HOU", "Rare", 2, 65481) AngelofCondemnation = Card("angel_of_condemnation", "Angel of Condemnation", ['2', 'W', 'W'], ['W'], "Creature", "Angel", "HOU", "Rare", 3, 65483) AngeloftheGodPharaoh = Card("angel_of_the_godpharaoh", "Angel of the God-Pharaoh", ['4', 'W', 'W'], ['W'], "Creature", "Angel", "HOU", "Uncommon", 4, 65485) AvenofEnduringHope = Card("aven_of_enduring_hope", "Aven of Enduring Hope", ['4', 'W'], ['W'], "Creature", "Bird Cleric", "HOU", "Common", 5, 65487) CrestedSunmare = Card("crested_sunmare", "Crested Sunmare", ['3', 'W', 'W'], ['W'], "Creature", "Horse", "HOU", "Mythic Rare", 6, 65489) DauntlessAven = Card("dauntless_aven", "Dauntless Aven", ['2', 'W'], ['W'], "Creature", "Bird Warrior", "HOU", "Common", 7, 65491) DesertsHold = Card("deserts_hold", "Desert's Hold", ['2', 'W'], ['W'], "Enchantment", "Aura", "HOU", "Uncommon", 8, 65493) # mixup start DisposalMummy = Card("disposal_mummy", "Disposal Mummy", ['2', 'W'], ['W'], "Creature", "Zombie Jackal", "HOU", "Common", 9, 65957) DjeruWithEyesOpen = Card("djeru_with_eyes_open", "Djeru, With Eyes Open", ['3', 'W', 'W'], ['W'], "Legendary Creature", "Human Warrior", "HOU", "Rare", 10, 65495)
import app.set_data.dom as dom import app.set_data.weird as weird all_mtga_cards = set.Pool.from_sets("mtga_cards", sets=[rix.RivalsOfIxalan, xln.Ixalan, hou.HourOfDevastation, akh.Amonkhet, dom.Dominaria, weird.WeirdLands]) ''') import sys, os, time sys.path.append("./mtga_tracker") from util import all_mtga_cards from app.models.card import Card from urllib.request import urlretrieve all_mtga_cards.cards.append( Card("warrior_token", "Warrior Token", [], [], "Token Creature", "", "TAKH", 17, 66580)) for card in all_mtga_cards.cards: if card.set_number < 0: continue folder = "cards/{:02d}".format(card.mtga_id % 20) if not os.path.exists(folder): os.makedirs(folder) url = "https://img.scryfall.com/cards/normal/en/{}/{:d}.jpg".format( card.set.lower(), card.set_number) path = "{}/{:d}.jpg".format(folder, card.mtga_id) if not os.path.exists(path): print("{} -> {}".format(url, path)) try: urlretrieve(url, path)
import sys from app.models.card import Card from app.models.set import Set import inspect KarnScionofUrza = Card("karn_scion_of_urza", "Karn, Scion of Urza", ['4'], [], "Legendary Planeswalker", "Karn", "DOM", "Mythic Rare", 1, 67106) AdamantWill = Card("adamant_will", "Adamant Will", ['1', 'W'], ['W'], "Instant", "", "DOM", "Common", 2, 67108) AvenSentry = Card("aven_sentry", "Aven Sentry", ['3', 'W'], ['W'], "Creature", "Bird Soldier", "DOM", "Common", 3, 67110) BairdStewardofArgive = Card("baird_steward_of_argive", "Baird, Steward of Argive", ['2', 'W', 'W'], ['W'], "Legendary Creature", "Human Soldier", "DOM", "Uncommon", 4, 67112) BenalishHonorGuard = Card("benalish_honor_guard", "Benalish Honor Guard", ['1', 'W'], ['W'], "Creature", "Human Knight", "DOM", "Common", 5, 67114) BenalishMarshal = Card("benalish_marshal", "Benalish Marshal", ['W', 'W', 'W'], ['W'], "Creature", "Human Knight", "DOM", "Rare", 6, 67116) BlessedLight = Card("blessed_light", "Blessed Light", ['4', 'W'], ['W'], "Instant", "", "DOM", "Common", 7, 67118) BoardtheWeatherlight = Card("board_the_weatherlight", "Board the Weatherlight", ['1', 'W'], ['W'], "Sorcery", "", "DOM", "Uncommon", 8, 67120) CalltheCavalry = Card("call_the_cavalry", "Call the Cavalry", ['3', 'W'], ['W'], "Sorcery", "", "DOM", "Common", 9, 67122) Charge = Card("charge", "Charge", ['W'], ['W'], "Instant", "", "DOM", "Common", 10, 67124)
import sys from app.models.card import Card from app.models.set import Set import inspect AerialModification = Card("aerial_modification", "Aerial Modification", ['4', 'W'], ['W'], "Enchantment", "Aura", "AER", 1, 64213) AeronautAdmiral = Card("aeronaut_admiral", "Aeronaut Admiral", ['3', 'W'], ['W'], "Creature", "Human Pilot", "AER", 2, 64207) AetherInspector = Card("aether_inspector", "Aether Inspector", ['3', 'W'], ['W'], "Creature", "Dwarf Artificer", "AER", 3, 64541) AethergeodeMiner = Card("aethergeode_miner", "Aethergeode Miner", ['1', 'W'], ['W'], "Creature", "Dwarf Scout", "AER", 4, 64543) AirdropAeronauts = Card("airdrop_aeronauts", "Airdrop Aeronauts", ['3', 'W', 'W'], ['W'], "Creature", "Dwarf Scout", "AER", 5, 64211) AlleyEvasion = Card("alley_evasion", "Alley Evasion", ['W'], ['W'], "Instant", "", "AER", 6, 64545) AudaciousInfiltrator = Card("audacious_infiltrator", "Audacious Infiltrator", ['1', 'W'], ['W'], "Creature", "Dwarf Rogue", "AER", 7, 64547) BastionEnforcer = Card("bastion_enforcer", "Bastion Enforcer", ['2', 'W'], ['W'], "Creature", "Dwarf Soldier", "AER", 8, 64187) CallforUnity = Card("call_for_unity", "Call for Unity", ['3', 'W', 'W'], ['W'], "Enchantment", "", "AER", 9, 64219) CaughtintheBrights = Card("caught_in_the_brights", "Caught in the Brights", ['2', 'W'], ['W'], "Enchantment", "Aura", "AER", 10, 64197) ConsulateCrackdown = Card("consulate_crackdown", "Consulate Crackdown", ['3', 'W', 'W'], ['W'], "Enchantment", "", "AER", 11,
import sys from app.models.card import Card from app.models.set import Set import inspect AcrobaticManeuver = Card("acrobatic_maneuver", "Acrobatic Maneuver", ['2', 'W'], ['W'], "Instant", "", "KLD", "Common", 1, 63641) AerialResponder = Card("aerial_responder", "Aerial Responder", ['1', 'W', 'W'], ['W'], "Creature", "Dwarf Soldier", "KLD", "Uncommon", 2, 63643) AetherstormRoc = Card("aetherstorm_roc", "Aetherstorm Roc", ['2', 'W', 'W'], ['W'], "Creature", "Bird", "KLD", "Rare", 3, 63645) AngelofInvention = Card("angel_of_invention", "Angel of Invention", ['3', 'W', 'W'], ['W'], "Creature", "Angel", "KLD", "Mythic Rare", 4, 63647) AuthorityoftheConsuls = Card("authority_of_the_consuls", "Authority of the Consuls", ['W'], ['W'], "Enchantment", "", "KLD", "Rare", 5, 63649) AviaryMechanic = Card("aviary_mechanic", "Aviary Mechanic", ['1', 'W'], ['W'], "Creature", "Dwarf Artificer", "KLD", "Common", 6, 63651) BuilttoLast = Card("built_to_last", "Built to Last", ['W'], ['W'], "Instant", "", "KLD", "Common", 7, 63653) CapturedbytheConsulate = Card("captured_by_the_consulate", "Captured by the Consulate", ['3', 'W'], ['W'], "Enchantment", "Aura", "KLD", "Rare", 8, 63655) CataclysmicGearhulk = Card("cataclysmic_gearhulk", "Cataclysmic Gearhulk", ['3', 'W', 'W'], ['W'], "Artifact Creature", "Construct", "KLD", "Mythic Rare", 9, 63657) ConsulateSurveillance = Card("consulate_surveillance", "Consulate Surveillance", ['3', 'W'], ['W'],
import sys from app.models.card import Card from app.models.set import Set import inspect AngelofSanctions = Card("angel_of_sanctions", "Angel of Sanctions", ['3', 'W', 'W'], ['W'], "Creature", "Angel", "AKH", 1, 64801) AnointedProcession = Card("anointed_procession", "Anointed Procession", ['3', 'W'], ['W'], "Enchantment", "", "AKH", 2, 64803) AnointerPriest = Card("anointer_priest", "Anointer Priest", ['1', 'W'], ['W'], "Creature", "Human Cleric", "AKH", 3, 64805) ApproachoftheSecondSun = Card("approach_of_the_second_sun", "Approach of the Second Sun", ['6', 'W'], ['W'], "Sorcery", "", "AKH", 4, 64807) AvenMindcensor = Card("aven_mindcensor", "Aven Mindcensor", ['2', 'W'], ['W'], "Creature", "Bird Wizard", "AKH", 5, 64809) BindingMummy = Card("binding_mummy", "Binding Mummy", ['1', 'W'], ['W'], "Creature", "Zombie", "AKH", 6, 64811) CartoucheofSolidarity = Card("cartouche_of_solidarity", "Cartouche of Solidarity", ['W'], ['W'], "Enchantment", "Aura Cartouche", "AKH", 7, 64813) CastOut = Card("cast_out", "Cast Out", ['3', 'W'], ['W'], "Enchantment", "", "AKH", 8, 64815) CompulsoryRest = Card("compulsory_rest", "Compulsory Rest", ['1', 'W'], ['W'], "Enchantment", "Aura", "AKH", 9, 64817) DevotedCropMate = Card("devoted_cropmate", "Devoted Crop-Mate", ['2', 'W'], ['W'], "Creature", "Human Warrior", "AKH", 10, 64819) DjerusResolve = Card("djerus_resolve", "Djeru's Resolve", ['W'], ['W'], "Instant", "", "AKH", 11, 64821)
class TestCard(unittest.TestCase): card = None def setUp(self): self.card = Card({ 'name': 'Keldon Warcaller', 'manacost': '5GBR', 'type': 'Legendary Creature', 'sub_types': ['Elemental'], 'set': 'dom', 'rules_text': 'Creatures you control have haste. Cascade, cascade (When you cast this spell, exile cards from the top of your library until you exile a nonland card that costs less. You may cast it without paying its mana cost. Put the exiled cards on the bottom of your library in a random order. Then do it again.)', 'flavor': 'Test flavor', 'artist': 'Thomas M. Baxa', 'power': '7', 'toughness': '5', 'url': 'http://mythicspoiler.com/dom/cards/keldonwarcaller.html', }) def test_get_name(self): # Act result = self.card.get_name() # Assert self.assertEquals(result, 'Keldon Warcaller') def test_get_normalized_name_from_name(self): # Act result = self.card.get_normalized_name() # Assert self.assertEquals(result, 'keldonwarcaller') def test_get_normalized_name_from_url(self): # Arrange self.card.name = None # Act result = self.card.get_normalized_name() # Assert self.assertEquals(result, 'keldonwarcaller') def test_get_manacost(self): # Act result = self.card.get_manacost() # Assert self.assertEquals(result, '5GBR') def test_get_cmc(self): # Act result = self.card.get_cmc() # Assert self.assertEquals(result, 8) def test_get_type(self): # Act result = self.card.get_type() # Assert self.assertEquals(result, 'Legendary Creature') def test_get_subtypes(self): # Act result = self.card.get_sub_types() # Assert self.assertEquals(result, ['Elemental']) def test_get_subtypes_string(self): # Act result = self.card.get_sub_types_string() # Assert self.assertEquals(result, 'Elemental ') def test_get_set(self): # Act result = self.card.get_set() # Assert self.assertEquals(result, 'dom') def test_get_rules_text(self): # Act result = self.card.get_rules_text() # Assert self.assertEquals( result, 'Creatures you control have haste. Cascade, cascade (When you cast this spell, exile cards from the top of your library until you exile a nonland card that costs less. You may cast it without paying its mana cost. Put the exiled cards on the bottom of your library in a random order. Then do it again.)' ) def test_get_flavor(self): # Act result = self.card.get_flavor() # Assert self.assertEquals(result, 'Test flavor') def test_get_artist(self): # Act result = self.card.get_artist() # Assert self.assertEquals(result, 'Thomas M. Baxa') def test_get_power(self): # Act result = self.card.get_power() # Assert self.assertEquals(result, '7') def test_get_toughness(self): # Act result = self.card.get_toughness() # Assert self.assertEquals(result, '5') def test_get_image_filename_from_name(self): # Act result = self.card.get_image_filename() # Assert self.assertEquals(result, 'dom_keldonwarcaller') def test_get_image_filename_from_url(self): # Arrange self.card.name = None # Act result = self.card.get_image_filename() # Assert self.assertEquals(result, 'dom_keldonwarcaller90')