1 | ## |
---|
2 | ## test_interfaces.py |
---|
3 | ## Login : <uli@pu.smp.net> |
---|
4 | ## Started on Mon Aug 23 01:59:52 2010 Uli Fouquet |
---|
5 | ## $Id$ |
---|
6 | ## |
---|
7 | ## Copyright (C) 2010 Uli Fouquet |
---|
8 | ## This program is free software; you can redistribute it and/or modify |
---|
9 | ## it under the terms of the GNU General Public License as published by |
---|
10 | ## the Free Software Foundation; either version 2 of the License, or |
---|
11 | ## (at your option) any later version. |
---|
12 | ## |
---|
13 | ## This program is distributed in the hope that it will be useful, |
---|
14 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
15 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
16 | ## GNU General Public License for more details. |
---|
17 | ## |
---|
18 | ## You should have received a copy of the GNU General Public License |
---|
19 | ## along with this program; if not, write to the Free Software |
---|
20 | ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
21 | ## |
---|
22 | """Tests for jambtable interfaces. |
---|
23 | """ |
---|
24 | import unittest |
---|
25 | from zc.sourcefactory.browser.source import FactoredTerms |
---|
26 | from zope.browser.interfaces import ITerms |
---|
27 | from zope.component import getMultiAdapter |
---|
28 | from zope.publisher.browser import TestRequest |
---|
29 | from waeup.sirp.jambtables.interfaces import GenderSource |
---|
30 | |
---|
31 | class InterfacesTest(unittest.TestCase): |
---|
32 | |
---|
33 | def setUp(self): |
---|
34 | self.source = GenderSource() |
---|
35 | self.request = TestRequest() |
---|
36 | self.terms = FactoredTerms(self.source, self.request) |
---|
37 | return |
---|
38 | |
---|
39 | def tearDown(self): |
---|
40 | pass |
---|
41 | |
---|
42 | def test_GenderSource_list(self): |
---|
43 | result = list(self.source) |
---|
44 | self.assertEqual(result, ['m', 'f']) |
---|
45 | |
---|
46 | def test_GenderSource_term_male(self): |
---|
47 | term = self.terms.getTerm('m') |
---|
48 | assert term.title == 'male' |
---|
49 | assert term.token == 'm' |
---|
50 | assert term.value == 'm' |
---|
51 | |
---|
52 | def test_GenderSource_term_female(self): |
---|
53 | term = self.terms.getTerm('f') |
---|
54 | assert term.title == 'female' |
---|
55 | assert term.token == 'f' |
---|
56 | assert term.value == 'f' |
---|
57 | |
---|
58 | def test_GernderSource_term_invalid(self): |
---|
59 | term_inv = self.terms.getTerm('Invalid') |
---|
60 | assert term_inv.title is None |
---|
61 | assert term_inv.token == 'i' |
---|
62 | |
---|
63 | def test_suite(): |
---|
64 | suite = unittest.TestSuite() |
---|
65 | for testcase in [ |
---|
66 | InterfacesTest, |
---|
67 | ]: |
---|
68 | suite.addTest(unittest.TestLoader().loadTestsFromTestCase( |
---|
69 | testcase |
---|
70 | ) |
---|
71 | ) |
---|
72 | return suite |
---|
73 | |
---|