source: main/waeup.sirp/branches/henrik-bootstrap/src/waeup/sirp/applicants/tests/test_interfaces.py @ 10009

Last change on this file since 10009 was 7193, checked in by Henrik Bettermann, 13 years ago

More copyright adjustments.

  • Property svn:keywords set to Id
File size: 2.9 KB
Line 
1## $Id: test_interfaces.py 7193 2011-11-25 07:21:29Z henrik $
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"""
19Test components defined in interface module.
20"""
21import unittest
22from zc.sourcefactory.browser.source import FactoredTerms
23from zope.publisher.browser import TestRequest
24from waeup.sirp.applicants.vocabularies import application_types_vocab
25from waeup.sirp.students.vocabularies import GenderSource
26
27class ApplicationCategoriesTestCase(unittest.TestCase):
28
29    def setUp(self):
30        self.vocab = application_types_vocab
31        return
32
33    def test_vocabulary_len(self):
34        self.assertEqual(len(self.vocab), 10)
35        return
36
37    def test_vocabulary_items(self):
38        self.assertTrue('pude' in self.vocab)
39        return
40
41    def test_term_attributes(self):
42        # Check that each vocab entry provided value, token, and title.
43        term = self.vocab.getTermByToken('pude')
44        self.assertEqual(term.token, 'pude')
45        self.assertEqual(term.value, 'pude')
46        self.assertEqual(term.title, 'Post UDE Screening')
47        return
48
49class InterfacesTest(unittest.TestCase):
50
51    def setUp(self):
52        self.source = GenderSource()
53        self.request = TestRequest()
54        self.terms = FactoredTerms(self.source, self.request)
55        return
56
57    def tearDown(self):
58        pass
59
60    def test_GenderSource_list(self):
61        result = list(self.source)
62        self.assertEqual(result, ['m', 'f'])
63
64    def test_GenderSource_term_male(self):
65        term = self.terms.getTerm('m')
66        assert term.title == 'Male'
67        assert term.token == 'm'
68        assert term.value == 'm'
69
70    def test_GenderSource_term_female(self):
71        term = self.terms.getTerm('f')
72        assert term.title == 'Female'
73        assert term.token == 'f'
74        assert term.value == 'f'
75
76    def test_GernderSource_term_invalid(self):
77        term_inv = self.terms.getTerm('Invalid')
78        assert term_inv.title is None
79        assert term_inv.token == 'i'
80
81def suite():
82    suite = unittest.TestSuite()
83    for testcase in [
84            ApplicationCategoriesTestCase,
85            InterfacesTest,
86            ]:
87        suite.addTests(unittest.TestLoader().loadTestsFromTestCase(testcase))
88    return suite
89
90test_suite = suite
91
92
Note: See TracBrowser for help on using the repository browser.