Skip to content

Commit 1df1746

Browse files
author
ravi
committed
all test cases for currency symbol and currency codes
1 parent 88c0106 commit 1df1746

1 file changed

Lines changed: 30 additions & 1 deletion

File tree

tests/test.py

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import datetime
22
from unittest import TestCase
3-
from forex_python.converter import CurrencyRates
3+
from forex_python.converter import CurrencyRates, CurrencyCodes
44
from forex_python.converter import RatesNotAvailableError
55

66

@@ -88,3 +88,32 @@ def test_amount_convert_date(self):
8888
def test_amount_convert_invalid_currency(self):
8989
# test if amount returned in float
9090
self.assertRaises(RatesNotAvailableError, self.c.convert, 'ABC', 'XYZ', 10)
91+
92+
93+
class TestCurrencySymbol(TestCase):
94+
"""
95+
test currency symbols from currency codes
96+
"""
97+
def setUp(self):
98+
self.c = CurrencyCodes()
99+
100+
def test_with_valid_currency_code(self):
101+
self.assertEqual(str(self.c.get_symbol('USD')), 'US$')
102+
103+
def test_with_invalid_currency_code(self):
104+
self.assertFalse(self.c.get_symbol('XYZ'))
105+
106+
107+
class TestCurrencyName(TestCase):
108+
"""
109+
test currency name from currency codes
110+
"""
111+
def setUp(self):
112+
self.c = CurrencyCodes()
113+
114+
def test_with_valid_currency_code(self):
115+
self.assertEqual(str(self.c.get_currency_name('USD')), 'United States dollar')
116+
117+
def test_with_invalid_currency_code(self):
118+
self.assertFalse(self.c.get_currency_name('XYZ'))
119+

0 commit comments

Comments
 (0)