forked from tiyd-python-2015-01/currency-converter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_currency.py
45 lines (26 loc) · 985 Bytes
/
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
39
40
41
42
43
44
45
from currency import *
rates = [('USD', 'EUR', 0.86),
('USD', 'JPY', 118.68),
('GBP', 'USD', 1.51),
('USD', 'CHF', 0.87),
('USD', 'CAD', 1.21),
('EUR', 'JPY', 137.08),
('AUD', 'USD', 0.82)]
def test_convert_same():
assert convert(rates[0][2], 1, 'USD', 'USD') == 1
def test_convert_USDtoEUR():
assert convert(rates[0][2], 1, 'USD', 'EUR') == 0.86
def test_value_other_than_1():
assert convert(rates[0][2], 2, 'USD', 'EUR') == 1.72
def test_convert_EURtoUSD():
assert convert(rates[1][2], 1, 'EUR', 'USD') == 1.16
def test_get_rate_normal():
assert get_rate('USD', 'EUR') == 0.86
def test_get_rate_inverse():
assert get_rate('EUR', 'USD') == 1.16
def test_convert_GBPtoUSD():
assert convert(rates, 2, 'GBP', 'USD') == 3.02
def test_convert_USDtoGBP():
assert convert(rates, 2, 'USD', 'GBP') == 1.32
def test_convert_EURtoJPY():
assert convert(rates, 3, 'EUR', 'JPY') == 411.24