1 | ## |
---|
2 | ## test_applicants.py |
---|
3 | ## Login : <uli@pu.smp.net> |
---|
4 | ## Started on Tue Aug 24 04:36:11 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 applicants and related. |
---|
23 | """ |
---|
24 | import logging |
---|
25 | import unittest |
---|
26 | from StringIO import StringIO |
---|
27 | from zope.component.interfaces import IFactory |
---|
28 | from zope.interface import verify |
---|
29 | from waeup.sirp.interfaces import IWAeUPSIRPPluggable |
---|
30 | from waeup.sirp.applicants.jambtables import ( |
---|
31 | ResultEntry, Applicant, ApplicantFactory, ApplicantContainer, |
---|
32 | ) |
---|
33 | from waeup.sirp.applicants.jambtables.interfaces import ( |
---|
34 | IResultEntry, IApplicant, IApplicantContainer, |
---|
35 | ) |
---|
36 | |
---|
37 | class ResultEntryTest(unittest.TestCase): |
---|
38 | |
---|
39 | def setUp(self): |
---|
40 | self.result_entry = ResultEntry() |
---|
41 | return |
---|
42 | |
---|
43 | def tearDown(self): |
---|
44 | pass |
---|
45 | |
---|
46 | def test_interfaces(self): |
---|
47 | verify.verifyClass(IResultEntry, ResultEntry) |
---|
48 | verify.verifyObject(IResultEntry, self.result_entry) |
---|
49 | |
---|
50 | def test_resultentry(self): |
---|
51 | entry = ResultEntry('Some subject', 3.7) |
---|
52 | assert entry.subject == 'Some subject' |
---|
53 | assert entry.score == 3.7 |
---|
54 | |
---|
55 | class ApplicantTest(unittest.TestCase): |
---|
56 | |
---|
57 | def setUp(self): |
---|
58 | self.applicant = Applicant() |
---|
59 | |
---|
60 | def tearDown(self): |
---|
61 | pass |
---|
62 | |
---|
63 | def test_interfaces(self): |
---|
64 | verify.verifyClass(IApplicant, Applicant) |
---|
65 | verify.verifyObject(IApplicant, self.applicant) |
---|
66 | |
---|
67 | class ApplicantFactoryTest(unittest.TestCase): |
---|
68 | |
---|
69 | def setUp(self): |
---|
70 | self.factory = ApplicantFactory() |
---|
71 | |
---|
72 | def tearDown(self): |
---|
73 | pass |
---|
74 | |
---|
75 | def test_interfaces(self): |
---|
76 | verify.verifyClass(IFactory, ApplicantFactory) |
---|
77 | verify.verifyObject(IFactory, self.factory) |
---|
78 | |
---|
79 | def test_factory(self): |
---|
80 | obj = self.factory() |
---|
81 | assert isinstance(obj, Applicant) |
---|
82 | |
---|
83 | def test_getInterfaces(self): |
---|
84 | implemented_by = self.factory.getInterfaces() |
---|
85 | assert implemented_by.isOrExtends(IApplicant) |
---|
86 | |
---|
87 | class ApplicantContainerTest(unittest.TestCase): |
---|
88 | |
---|
89 | def setUp(self): |
---|
90 | self.container = ApplicantContainer() |
---|
91 | return |
---|
92 | |
---|
93 | def tearDown(self): |
---|
94 | pass |
---|
95 | |
---|
96 | def test_interfaces(self): |
---|
97 | verify.verifyClass(IApplicantContainer, ApplicantContainer) |
---|
98 | verify.verifyObject(IApplicantContainer, self.container) |
---|
99 | |
---|
100 | |
---|
101 | def test_suite(): |
---|
102 | suite = unittest.TestSuite() |
---|
103 | for testcase in [ |
---|
104 | ResultEntryTest, ApplicantTest, ApplicantFactoryTest, |
---|
105 | ApplicantContainerTest, |
---|
106 | ]: |
---|
107 | suite.addTest(unittest.TestLoader().loadTestsFromTestCase( |
---|
108 | testcase |
---|
109 | ) |
---|
110 | ) |
---|
111 | return suite |
---|