- Timestamp:
- 22 Dec 2014, 13:49:14 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.ikoba/branches/uli-payments/src/waeup/ikoba/payments/tests/test_currencies.py
r12248 r12294 1 1 import unittest 2 from zope.i18nmessageid.message import Message as i18nMessage 3 from zope.interface.verify import verifyObject 4 from zope.schema.interfaces import IVocabularyTokenized, ITerm 2 5 from waeup.ikoba.payments.currencies import ( 3 get_decimal_units, ISO_4217_CURRENCIES, 6 get_decimal_units, ISO_4217_CURRENCIES, ISO_4217_CURRENCIES_VOCAB, 4 7 ) 5 8 … … 10 13 # we can get the number of decimals for a currency code 11 14 assert get_decimal_units('USD') == 2 15 assert get_decimal_units('JPY') == 0 12 16 13 17 def test_iso_currencies_no_linebreak(self): … … 17 21 assert '\n' not in value[0] 18 22 assert '\n' not in value[1] 23 24 def test_iso_currencies_types(self): 25 # sanity check: make sure we have the correct types in all tuples 26 for key, value in ISO_4217_CURRENCIES.items(): 27 assert isinstance(value[1], i18nMessage) 28 assert isinstance(value[2], int) 29 assert isinstance(value[3], str) 30 31 def test_currencies_vocab_tokenized(self): 32 # we can get ISO currencies as a source suitable for forms etc. 33 verifyObject(IVocabularyTokenized, ISO_4217_CURRENCIES_VOCAB) 34 35 def test_currencies_vocab_i18nized(self): 36 # vocab titles are i18nized 37 result = ISO_4217_CURRENCIES_VOCAB.getTerm('USD') 38 assert ITerm.providedBy(result) 39 self.assertEqual(result.title, u'US Dollar') 40 assert isinstance(result.title, i18nMessage) 41 42 def test_currencies_vocab_tokens_are_string(self): 43 # vocab tokens are simple strings 44 result = ISO_4217_CURRENCIES_VOCAB.getTerm('USD') 45 assert ITerm.providedBy(result) 46 assert result.token == result.value 47 assert result.value == 'USD' 48 assert isinstance(result.token, str) 49 assert isinstance(result.value, str)
Note: See TracChangeset for help on using the changeset viewer.