1 | ## |
---|
2 | ## test_util.py |
---|
3 | ## Login : <uli@pu.smp.net> |
---|
4 | ## Started on Sun Aug 22 19:56: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 jambtables and applicants helper tools. |
---|
23 | """ |
---|
24 | import unittest |
---|
25 | from zope.component.hooks import setSite, clearSite |
---|
26 | from zope.site import LocalSiteManager |
---|
27 | from waeup.sirp.applicants.jambtables.util import ( |
---|
28 | application_exists, get_applicant_data |
---|
29 | ) |
---|
30 | from waeup.sirp.app import University |
---|
31 | from waeup.sirp.applicants import Applicant |
---|
32 | from waeup.sirp.applicants.container import ApplicantsContainer |
---|
33 | from waeup.sirp.testing import WAeUPSIRPUnitTestLayer |
---|
34 | |
---|
35 | fake_apps = { |
---|
36 | 'pude10' : ApplicantsContainer(), |
---|
37 | 'pude11' : ApplicantsContainer(), |
---|
38 | } |
---|
39 | |
---|
40 | fake_apps['pude10']['APP-99999'] = Applicant() |
---|
41 | |
---|
42 | |
---|
43 | class HelperToolsTest(unittest.TestCase): |
---|
44 | |
---|
45 | layer = WAeUPSIRPUnitTestLayer |
---|
46 | |
---|
47 | def setUp(self): |
---|
48 | self.app = University() |
---|
49 | # Fill up some JAMB data... |
---|
50 | self.app['jambdata']['91100546DD'] = Applicant() |
---|
51 | self.app['jambdata']['91100546DE'] = Applicant() |
---|
52 | # Insert some applicants... |
---|
53 | for container, data in fake_apps.items(): |
---|
54 | self.app['applicants'][container] = data |
---|
55 | self.app.setSiteManager(LocalSiteManager(self.app)) |
---|
56 | setSite(self.app) |
---|
57 | return |
---|
58 | |
---|
59 | def tearDown(self): |
---|
60 | clearSite() |
---|
61 | return |
---|
62 | |
---|
63 | def test_application_exists(self): |
---|
64 | result = application_exists('APP-99999') |
---|
65 | assert result is False |
---|
66 | |
---|
67 | result = application_exists('APP-44444') |
---|
68 | assert result is True |
---|
69 | return |
---|
70 | |
---|
71 | |
---|
72 | def test_suite(): |
---|
73 | suite = unittest.TestSuite() |
---|
74 | for testcase in [ |
---|
75 | HelperToolsTest, |
---|
76 | ]: |
---|
77 | suite.addTests(unittest.makeSuite(testcase)) |
---|
78 | return suite |
---|