/
test_card.py
72 lines (59 loc) · 3.9 KB
/
test_card.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# This file is part of mtgsdk.
# https://github.com/MagicTheGathering/mtg-sdk-python
# Licensed under the MIT license:
# http://www.opensource.org/licenses/MIT-license
# Copyright (c) 2016, Andrew Backes <backes.andrew@gmail.com>
import vcr
import unittest
from mtgsdk import Card
# Python 3.6 Workaround until https://github.com/kevin1024/vcrpy/issues/293 is fixed.
vcr_connection_request = vcr.stubs.VCRConnection.request
vcr.stubs.VCRConnection.request = lambda *args, **kwargs: vcr_connection_request(*args)
class TestCard(unittest.TestCase):
def test_find_returns_card(self):
with vcr.use_cassette('fixtures/choice_of_damnations.yaml'):
card = Card.find(88803)
self.assertEqual('Choice of Damnations', card.name)
self.assertEqual('{5}{B}', card.mana_cost)
self.assertEqual(6, card.cmc)
self.assertEqual('Sorcery — Arcane', card.type)
self.assertTrue('Black' in card.colors)
self.assertEqual(['B'], card.color_identity)
self.assertTrue('Sorcery' in card.types)
self.assertTrue('Arcane' in card.subtypes)
self.assertEqual('Rare', card.rarity)
self.assertEqual('SOK', card.set)
self.assertEqual('Saviors of Kamigawa', card.set_name)
self.assertEqual("Target opponent chooses a number. You may have that player lose that much life. If you don't, that player sacrifices all but that many permanents.", card.text)
self.assertEqual("\"Life is a series of choices between bad and worse.\" —Toshiro Umezawa", card.flavor)
self.assertEqual('Tim Hildebrandt', card.artist)
self.assertEqual('62', card.number)
self.assertEqual(88803, card.multiverse_id)
self.assertEqual('http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=88803&type=card', card.image_url)
self.assertTrue(len(card.rulings) > 0)
self.assertTrue({"name":"Scelta della Dannazione","text" : "L'avversario bersaglio sceglie un numero. Puoi far perdere a quel giocatore un ammontare di punti vita pari a quel numero. Se non lo fai, quel giocatore sacrifica tutti i permanenti tranne un numero di permanenti pari al numero scelto.","flavor" : "\"La vita è una sequela di scelte tra male e peggio.\"\n—Toshiro Umezawa","imageUrl":"http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=105393&type=card","language":"Italian","multiverseid":105393} in card.foreign_names)
self.assertTrue('SOK' in card.printings)
self.assertEqual("Target opponent chooses a number. You may have that player lose that much life. If you don't, that player sacrifices all but that many permanents.", card.original_text)
self.assertEqual('Sorcery - Arcane', card.original_type)
self.assertTrue({"format":"Commander","legality":"Legal"} in card.legalities)
self.assertEqual('224a2a63-7be6-5e06-bf6b-e667727bf80b', card.id)
def test_all_with_params_return_cards(self):
with vcr.use_cassette('fixtures/legendary_elf_warriors.yaml'):
cards = Card.where(supertypes='legendary') \
.where(subtypes='elf,warrior') \
.all()
self.assertTrue(len(cards) >= 13)
def test_all_with_page_returns_cards(self):
with vcr.use_cassette('fixtures/all_first_page.yaml'):
cards = Card.where(page=1).all()
self.assertEqual(100, len(cards))
def test_all_with_page_and_page_size_returns_card(self):
with vcr.use_cassette('fixtures/all_first_page_one_card.yaml'):
cards = Card.where(page=1).where(pageSize=1).all()
self.assertEqual(1, len(cards))
def test_iter_with_no_where_returns_card(self):
with vcr.use_cassette('fixtures/cards_no_args.yaml'):
card = next(Card.iter())
self.assertIsInstance(card, Card)