source: main/waeup.sirp/trunk/src/waeup/sirp/jambtables/tests/test_interfaces.py @ 5475

Last change on this file since 5475 was 5469, checked in by uli, 14 years ago

Add tests for interfaces.

File size: 2.3 KB
Line 
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"""
24import unittest
25from zc.sourcefactory.browser.source import FactoredTerms
26from zope.browser.interfaces import ITerms
27from zope.component import getMultiAdapter
28from zope.publisher.browser import TestRequest
29from waeup.sirp.jambtables.interfaces import GenderSource
30
31class 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       
63def 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
Note: See TracBrowser for help on using the repository browser.