/
test_currency.py
39 lines (25 loc) · 1.31 KB
/
test_currency.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
import unittest
from currency import eur_to_usd, usd_to_eur, list_eur_to_usd, list_usd_to_eur, Money
class ConTest(unittest.TestCase):
def test_check_if_eur_convert_to_usd(self):
self.assertEqual(eur_to_usd(0.9), 1)
def test_check_if_usd_convert_to_eur(self):
self.assertEqual(usd_to_eur(1), .9)
def test_does_list_of_eur_convert_to_usd(self):
self.assertEqual(list_eur_to_usd([.9]), [1])
def test_longer_list_of_eur_convert_to_usd(self):
self.assertEqual(list_eur_to_usd([.9, 90, 1.8]), [1, 100, 2])
def test_list_of_usd_convert_to_eur(self):
self.assertEqual(list_usd_to_eur([1, 2, 100]), [.9, 1.80, 90])
# Test the Money class for correct conversions
class MoneyConTest(unittest.TestCase):
def test_check_if_eur_convert_to_usd(self):
self.assertEqual(Money().eur_to_usd(.9), 1)
def test_check_if_usd_convert_to_eur(self):
self.assertEqual(Money().usd_to_eur(1), .9)
def test_does_list_of_eur_convert_to_usd(self):
self.assertEqual(Money().list_eur_to_usd([.9]), [1])
def test_longer_list_of_eur_convert_to_usd(self):
self.assertEqual(Money().list_eur_to_usd([.9, 90, 1.8]), [1, 100, 2])
def test_list_of_usd_convert_to_eur(self):
self.assertEqual(Money().list_usd_to_eur([1, 2, 100]), [.9, 1.80, 90])