1 | ## $Id: test_interfaces.py 7811 2012-03-08 19:00:51Z uli $ |
---|
2 | ## |
---|
3 | ## Copyright (C) 2011 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 | ## |
---|
18 | """ |
---|
19 | Test components defined in interface module. |
---|
20 | """ |
---|
21 | import unittest |
---|
22 | from zc.sourcefactory.browser.source import FactoredTerms |
---|
23 | from zope.publisher.browser import TestRequest |
---|
24 | from waeup.kofa.applicants.interfaces import ApplicationTypeSource |
---|
25 | from waeup.kofa.students.vocabularies import GenderSource |
---|
26 | |
---|
27 | class InterfacesTest(unittest.TestCase): |
---|
28 | |
---|
29 | def setUp(self): |
---|
30 | self.source = GenderSource() |
---|
31 | self.request = TestRequest() |
---|
32 | self.terms = FactoredTerms(self.source, self.request) |
---|
33 | return |
---|
34 | |
---|
35 | def tearDown(self): |
---|
36 | pass |
---|
37 | |
---|
38 | def test_GenderSource_list(self): |
---|
39 | result = list(self.source) |
---|
40 | self.assertEqual(result, ['m', 'f']) |
---|
41 | |
---|
42 | def test_GenderSource_term_male(self): |
---|
43 | term = self.terms.getTerm('m') |
---|
44 | assert term.title == 'Male' |
---|
45 | assert term.token == 'm' |
---|
46 | assert term.value == 'm' |
---|
47 | |
---|
48 | def test_GenderSource_term_female(self): |
---|
49 | term = self.terms.getTerm('f') |
---|
50 | assert term.title == 'Female' |
---|
51 | assert term.token == 'f' |
---|
52 | assert term.value == 'f' |
---|
53 | |
---|
54 | def test_GernderSource_term_invalid(self): |
---|
55 | term_inv = self.terms.getTerm('Invalid') |
---|
56 | assert term_inv.title is None |
---|
57 | assert term_inv.token == 'i' |
---|
58 | |
---|
59 | def suite(): |
---|
60 | suite = unittest.TestSuite() |
---|
61 | for testcase in [ |
---|
62 | InterfacesTest, |
---|
63 | ]: |
---|
64 | suite.addTests(unittest.TestLoader().loadTestsFromTestCase(testcase)) |
---|
65 | return suite |
---|
66 | |
---|
67 | test_suite = suite |
---|
68 | |
---|
69 | |
---|