source: main/waeup.sirp/trunk/src/waeup/sirp/applicants/tests/test_interfaces.py @ 7087

Last change on this file since 7087 was 7063, checked in by uli, 13 years ago

Merge changes from branch ulif-extimgstore back into trunk.
Beside external image storage also waeupdocs should work again.

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