def test_get_currencies_of_country(self): assert get_currencies_of_country("IN")[0] == Currency("INR") assert get_currencies_of_country("iN")[0] == Currency("INR") assert get_currencies_of_country("BT") == [ Currency("BTN"), Currency("INR") ] assert get_currencies_of_country("XX") == []
def test_init(self): usd_countries = CURRENCIES['USD'].countries US_dollars = Currency( code='USD', numeric='840', name='US Dollar', countries=['AMERICAN SAMOA', 'BRITISH INDIAN OCEAN TERRITORY', 'ECUADOR', 'GUAM', 'MARSHALL ISLANDS', 'MICRONESIA', 'NORTHERN MARIANA ISLANDS', 'PALAU', 'PUERTO RICO', 'TIMOR-LESTE', 'TURKS AND CAICOS ISLANDS', 'UNITED STATES', 'UNITED STATES MINOR OUTLYING ISLANDS', 'VIRGIN ISLANDS (BRITISH)', 'VIRGIN ISLANDS (U.S.)']) assert US_dollars.code == 'USD' assert US_dollars.countries == usd_countries assert US_dollars.name == 'US Dollar' assert US_dollars.numeric == '840'
def add_currency(code, numeric, name, countries): global CURRENCIES CURRENCIES[code] = Currency( code=code, numeric=numeric, name=name, countries=countries) return CURRENCIES[code]
def test_init(self): US_dollars = Currency( code='USD', numeric='840', sub_unit=100, name='United States Dollar', # NB deliberately not official name countries=['UNITED STATES']) assert US_dollars.code == 'USD' assert US_dollars.countries == ['UNITED STATES'] assert US_dollars.name == 'United States Dollar' assert US_dollars.numeric == '840' assert US_dollars.sub_unit == 100
def test_init(self): US_dollars = Currency( code="USD", numeric="840", sub_unit=100, name="United States Dollar", # NB deliberately not official name countries=["UNITED STATES"], ) assert US_dollars.code == "USD" assert US_dollars.countries == ["UNITED STATES"] assert US_dollars.name == "United States Dollar" assert US_dollars.numeric == "840" assert US_dollars.sub_unit == 100
def test_init(self): usd_countries = CURRENCIES['USD'].countries US_dollars = Currency( code='USD', numeric='840', name='US Dollar', countries=[ 'AMERICAN SAMOA', 'CARIBBEAN NETHERLANDS', 'CUBA', 'DIEGO GARCIA', 'DOMINICAN REPUBLIC', 'ECUADOR', 'MICRONESIA', 'GUAM', 'HAITI', 'BRITISH INDIAN OCEAN TERRITORY', 'MARSHALL ISLANDS', 'NORTHERN MARIANA ISLANDS', 'PANAMA', 'PUERTO RICO', 'PALAU', 'EL SALVADOR', 'TURKS & CAICOS ISLANDS', 'TIMOR-LESTE', 'U.S. OUTLYING ISLANDS', 'UNITED STATES', 'BRITISH VIRGIN ISLANDS', 'U.S. VIRGIN ISLANDS', 'ZIMBABWE', ], ) assert US_dollars.code == 'USD' assert US_dollars.countries == usd_countries assert US_dollars.name == 'US Dollar' assert US_dollars.numeric == '840'
def test_instance(self): instance = Currency() self.assertIsInstance(instance, Currency)
def test___eq__(self): currency1 = Currency() currency2 = Currency() self.assertEqual(currency1, currency2)
def test___repr__(self): instance = Currency(code='EUR') self.assertEqual(instance.__repr__(), 'EUR')
def test_countries(self): instance = Currency(countries=['Finland']) self.assertEqual(instance.countries, ['Finland'])
def test_name(self): instance = Currency(name='Euro') self.assertEqual(instance.name, 'Euro')
def test_name_default(self): instance = Currency() self.assertEqual(instance.name, '')
def test_numeric(self): instance = Currency(numeric='888') self.assertEqual(instance.numeric, '888')
def test_numeric_default(self): instance = Currency() self.assertEqual(instance.numeric, '999')
def test_code(self): instance = Currency(code='EUR') self.assertEqual(instance.code, 'EUR')
def test_code_default(self): instance = Currency() self.assertEqual(instance.code, '')
def test_countries_default(self): instance = Currency() self.assertEqual(instance.countries, [])