source: main/waeup.ikoba/trunk/src/waeup/ikoba/payments/tests/test_paypal_currencies.py

Last change on this file was 12752, checked in by Henrik Bettermann, 10 years ago

propset

  • Property svn:keywords set to Id
File size: 2.4 KB
Line 
1# $Id: test_paypal_currencies.py 12752 2015-03-12 10:19:49Z henrik $
2#
3# Copyright (C) 2014 Uli Fouquet & Henrik Bettermann
4# This program is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation; either version 2 of the License, or
7# (at your option) any later version.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program; if not, write to the Free Software
16# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17#
18import unittest
19from zope.i18nmessageid.message import Message as i18nMessage
20from zope.interface.verify import verifyObject
21from zope.schema.interfaces import IVocabularyTokenized, ITerm
22from waeup.ikoba.payments.paypal_currencies import (
23    CURRENCIES, CURRENCIES_VOCAB,
24    )
25
26
27class CurrencyTests(unittest.TestCase):
28
29    def test_currencies_is_dict(self):
30        # CURRENCIES is available
31        assert isinstance(CURRENCIES, dict)
32
33    def test_currencies_contains_i18n_messages(self):
34        # the CURRENCIES values are i18n messages
35        assert 'USD' in CURRENCIES.keys()
36        assert isinstance(CURRENCIES['USD'][0], i18nMessage)
37
38    def test_currencies_contain_domestic_infos(self):
39        # there is info about currencies valid domestic only avail.
40        CURRENCIES['USD'][1] is False
41        # there is info about whether the currency support decimals
42        CURRENCIES['USD'][2] is True
43
44
45class CurrenciesVocabTests(unittest.TestCase):
46
47    def test_currencies_vocab_tokenized(self):
48        # we can get a currencies source suitable for forms etc.
49        verifyObject(IVocabularyTokenized, CURRENCIES_VOCAB)
50
51    def test_currencies_vocab_i18nized(self):
52        # vocab titles are i18nized
53        result = CURRENCIES_VOCAB.getTerm('USD')
54        assert ITerm.providedBy(result)
55        self.assertEqual(result.title, u'United States dollar')
56        assert isinstance(result.title, i18nMessage)
57
58    def test_currencies_vocab_tokens_are_string(self):
59        # vocab tokens are simple strings
60        result = CURRENCIES_VOCAB.getTerm('USD')
61        assert ITerm.providedBy(result)
62        assert result.token == 'USD'
63        assert result.value == 'USD'
Note: See TracBrowser for help on using the repository browser.