This repository has been archived by the owner on Jan 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_price.py
50 lines (40 loc) · 1.52 KB
/
test_price.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
'''
test_price.py
A Unit Test Module for the MTG Price module.
Author: John Cleaver
License: BSD 3-Clause
'''
import unittest
import price
class PriceTestCase(unittest.TestCase):
"""Tests for price.py."""
def test_xml_return(self):
"""Tests to see if we get back XML from TCGPlayer"""
self.assertIn("<?xml",
price.get_tcgplayer_xml("Snap"),
"Looks like we did not get back XML from TCGPlayer.")
def test_html_error(self):
"""Tests to see what happens when TCGPlayer is down"""
self.assertRaises(price.requests.RequestException,
price.get_tcgplayer_xml,
"Snap",
"http://localhost/")
def test_xml_parse(self):
"""Tests if the XML was parsed correctly."""
card_name = "Bayou"
xml = price.get_tcgplayer_xml(card_name)
card_price = price.parse_tcg_player_xml(card_name, xml)
self.assertIsInstance(card_price,
price.TCGPrice)
for key, value in card_price:
self.assertTrue(value != "")
def test_card_not_found(self):
"""Tests to see what happens when a card does not exist."""
card_name = "nonexistingcard"
xml = price.get_tcgplayer_xml(card_name)
self.assertRaises(price.CardNotFoundError,
price.parse_tcg_player_xml,
card_name,
xml)
if __name__ == "__main__":
unittest.main()