[12179] | 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 |
---|
| 5 | from waeup.ikoba.payments.paypal_countries import COUNTRIES, COUNTRIES_VOCAB |
---|
| 6 | |
---|
| 7 | |
---|
| 8 | class CountryTests(unittest.TestCase): |
---|
| 9 | |
---|
| 10 | def test_countries_is_dict(self): |
---|
| 11 | # COUNTRIES is available |
---|
| 12 | assert isinstance(COUNTRIES, dict) |
---|
| 13 | |
---|
| 14 | def test_countries_contains_i18n_messages(self): |
---|
| 15 | # the COUNTRIES values are i18n messages |
---|
| 16 | assert 'DE' in COUNTRIES.keys() |
---|
| 17 | assert isinstance(COUNTRIES['DE'], i18nMessage) |
---|
| 18 | |
---|
| 19 | |
---|
| 20 | class CountriesVocabTests(unittest.TestCase): |
---|
| 21 | |
---|
| 22 | def test_countries_vocab_tokenized(self): |
---|
| 23 | # we can get a countries source suitable for forms etc. |
---|
| 24 | verifyObject(IVocabularyTokenized, COUNTRIES_VOCAB) |
---|
| 25 | |
---|
| 26 | def test_countries_vocab_i18nized(self): |
---|
| 27 | # vocab titles are i18nized |
---|
| 28 | result = COUNTRIES_VOCAB.getTerm('DE') |
---|
| 29 | assert ITerm.providedBy(result) |
---|
| 30 | self.assertEqual(result.title, u'GERMANY') |
---|
| 31 | assert isinstance(result.title, i18nMessage) |
---|
| 32 | |
---|
| 33 | def test_countries_vocab_tokens_are_string(self): |
---|
| 34 | # vocab tokens are simple strings |
---|
| 35 | result = COUNTRIES_VOCAB.getTerm('DE') |
---|
| 36 | assert ITerm.providedBy(result) |
---|
| 37 | assert result.token == 'DE' |
---|
| 38 | assert result.value == 'DE' |
---|