1 | ## |
---|
2 | ## test_batching.py |
---|
3 | ## Login : <uli@pu.smp.net> |
---|
4 | ## Started on Tue Aug 24 02:04:44 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 | """Unit tests for the applicant importer. |
---|
23 | """ |
---|
24 | import grok |
---|
25 | import unittest |
---|
26 | from zope.interface import verify |
---|
27 | from waeup.sirp.interfaces import IBatchProcessor |
---|
28 | from waeup.sirp.jambtables import ApplicantImporter |
---|
29 | |
---|
30 | class ApplicantImporterTest(unittest.TestCase): |
---|
31 | |
---|
32 | def setUp(self): |
---|
33 | self.importer = ApplicantImporter() |
---|
34 | self.site1 = dict( |
---|
35 | applications = { |
---|
36 | 'REG_NO_1': 'Application1', |
---|
37 | } |
---|
38 | ) |
---|
39 | return |
---|
40 | |
---|
41 | def tearDown(self): |
---|
42 | pass |
---|
43 | |
---|
44 | def test_interface(self): |
---|
45 | """Make sure we fulfill the interface contracts.""" |
---|
46 | assert verify.verifyObject(IBatchProcessor, self.importer) is True |
---|
47 | assert verify.verifyClass(IBatchProcessor, ApplicantImporter) is True |
---|
48 | |
---|
49 | def test_parentsExist(self): |
---|
50 | assert self.importer.parentsExist(None, dict()) is False |
---|
51 | assert self.importer.parentsExist(None, self.site1) is True |
---|
52 | |
---|
53 | def test_entryExists(self): |
---|
54 | assert self.importer.entryExists( |
---|
55 | dict(reg_no='REG_NONE'), self.site1) is False |
---|
56 | assert self.importer.entryExists( |
---|
57 | dict(reg_no='REG_NO_1'), self.site1) is True |
---|
58 | |
---|
59 | def test_getParent(self): |
---|
60 | parent = self.importer.getParent(None, self.site1) |
---|
61 | assert parent is self.site1['applications'] |
---|
62 | |
---|
63 | def test_getEntry(self): |
---|
64 | assert self.importer.getEntry( |
---|
65 | dict(reg_no='REG_NONE'), self.site1) is None |
---|
66 | assert self.importer.getEntry( |
---|
67 | dict(reg_no='REG_NO_1'), self.site1) == 'Application1' |
---|
68 | |
---|
69 | def test_addEntry(self): |
---|
70 | self.importer.addEntry( |
---|
71 | 'New application', dict(reg_no='REG_NO_99'), self.site1) |
---|
72 | assert self.site1['applications']['REG_NO_99'] == 'New application' |
---|
73 | |
---|
74 | def test_delEntry(self): |
---|
75 | self.importer.delEntry(dict(reg_no='REG_NO_1'), self.site1) |
---|
76 | assert 'REG_NO_1' not in self.site1['applications'].keys() |
---|
77 | |
---|
78 | def test_suite(): |
---|
79 | suite = unittest.TestSuite() |
---|
80 | for testcase in [ |
---|
81 | ApplicantImporterTest, |
---|
82 | ]: |
---|
83 | suite.addTest(unittest.TestLoader().loadTestsFromTestCase( |
---|
84 | testcase |
---|
85 | ) |
---|
86 | ) |
---|
87 | return suite |
---|