import unittest from zope.i18nmessageid.message import Message as i18nMessage from zope.interface.verify import verifyObject from zope.schema.interfaces import IVocabularyTokenized, ITerm from waeup.ikoba.payments.paypal_countries import COUNTRIES, COUNTRIES_VOCAB class CountryTests(unittest.TestCase): def test_countries_is_dict(self): # COUNTRIES is available assert isinstance(COUNTRIES, dict) def test_countries_contains_i18n_messages(self): # the COUNTRIES values are i18n messages assert 'DE' in COUNTRIES.keys() assert isinstance(COUNTRIES['DE'], i18nMessage) class CountriesVocabTests(unittest.TestCase): def test_countries_vocab_tokenized(self): # we can get a countries source suitable for forms etc. verifyObject(IVocabularyTokenized, COUNTRIES_VOCAB) def test_countries_vocab_i18nized(self): # vocab titles are i18nized result = COUNTRIES_VOCAB.getTerm('DE') assert ITerm.providedBy(result) self.assertEqual(result.title, u'GERMANY') assert isinstance(result.title, i18nMessage) def test_countries_vocab_tokens_are_string(self): # vocab tokens are simple strings result = COUNTRIES_VOCAB.getTerm('DE') assert ITerm.providedBy(result) assert result.token == 'DE' assert result.value == 'DE'