Beispiel #1
0
 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'
Beispiel #3
0
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
Beispiel #5
0
 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'
Beispiel #7
0
 def test_instance(self):
     instance = Currency()
     self.assertIsInstance(instance, Currency)
Beispiel #8
0
 def test___eq__(self):
     currency1 = Currency()
     currency2 = Currency()
     self.assertEqual(currency1, currency2)
Beispiel #9
0
 def test___repr__(self):
     instance = Currency(code='EUR')
     self.assertEqual(instance.__repr__(), 'EUR')
Beispiel #10
0
 def test_countries(self):
     instance = Currency(countries=['Finland'])
     self.assertEqual(instance.countries, ['Finland'])
Beispiel #11
0
 def test_name(self):
     instance = Currency(name='Euro')
     self.assertEqual(instance.name, 'Euro')
Beispiel #12
0
 def test_name_default(self):
     instance = Currency()
     self.assertEqual(instance.name, '')
Beispiel #13
0
 def test_numeric(self):
     instance = Currency(numeric='888')
     self.assertEqual(instance.numeric, '888')
Beispiel #14
0
 def test_numeric_default(self):
     instance = Currency()
     self.assertEqual(instance.numeric, '999')
Beispiel #15
0
 def test_code(self):
     instance = Currency(code='EUR')
     self.assertEqual(instance.code, 'EUR')
Beispiel #16
0
 def test_code_default(self):
     instance = Currency()
     self.assertEqual(instance.code, '')
Beispiel #17
0
 def test_countries_default(self):
     instance = Currency()
     self.assertEqual(instance.countries, [])
Beispiel #18
0
 def test___repr__(self):
     instance = Currency(code='EUR')
     self.assertEqual(instance.__repr__(), 'EUR')