1 | ## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann |
---|
2 | ## This program is free software; you can redistribute it and/or modify |
---|
3 | ## it under the terms of the GNU General Public License as published by |
---|
4 | ## the Free Software Foundation; either version 2 of the License, or |
---|
5 | ## (at your option) any later version. |
---|
6 | ## |
---|
7 | ## This program is distributed in the hope that it will be useful, |
---|
8 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
9 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
10 | ## GNU General Public License for more details. |
---|
11 | ## |
---|
12 | ## You should have received a copy of the GNU General Public License |
---|
13 | ## along with this program; if not, write to the Free Software |
---|
14 | ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
15 | ## |
---|
16 | """ |
---|
17 | Tests for payment containers. |
---|
18 | """ |
---|
19 | import unittest |
---|
20 | import tempfile |
---|
21 | import shutil |
---|
22 | from zope.interface.verify import verifyClass, verifyObject |
---|
23 | from zope.component.interfaces import IFactory |
---|
24 | from zope.component.hooks import setSite, clearSite |
---|
25 | from waeup.sirp.app import University |
---|
26 | from waeup.sirp.payments.interfaces import ( |
---|
27 | IPaymentsContainer, |
---|
28 | ) |
---|
29 | from waeup.sirp.payments.container import ( |
---|
30 | PaymentsContainer, |
---|
31 | ) |
---|
32 | from waeup.sirp.testing import ( |
---|
33 | FunctionalLayer, FunctionalTestCase, get_all_loggers, remove_new_loggers, |
---|
34 | remove_logger) |
---|
35 | |
---|
36 | class PaymentsContainerTestCase(FunctionalTestCase): |
---|
37 | |
---|
38 | layer = FunctionalLayer |
---|
39 | |
---|
40 | def setUp(self): |
---|
41 | remove_logger('waeup.sirp.app.students') |
---|
42 | super(PaymentsContainerTestCase, self).setUp() |
---|
43 | # Setup a sample site for each test |
---|
44 | # Prepopulate the ZODB... |
---|
45 | app = University() |
---|
46 | self.getRootFolder()['app'] = app |
---|
47 | self.app = self.getRootFolder()['app'] |
---|
48 | setSite(self.app) |
---|
49 | self.dc_root = tempfile.mkdtemp() |
---|
50 | app['datacenter'].setStoragePath(self.dc_root) |
---|
51 | return |
---|
52 | |
---|
53 | def tearDown(self): |
---|
54 | super(PaymentsContainerTestCase, self).tearDown() |
---|
55 | clearSite() |
---|
56 | shutil.rmtree(self.dc_root) |
---|
57 | return |
---|
58 | |
---|
59 | def test_interfaces(self): |
---|
60 | # Make sure the correct interfaces are implemented. |
---|
61 | self.assertTrue( |
---|
62 | verifyClass( |
---|
63 | IPaymentsContainer, PaymentsContainer) |
---|
64 | ) |
---|
65 | self.assertTrue( |
---|
66 | verifyObject( |
---|
67 | IPaymentsContainer, PaymentsContainer()) |
---|
68 | ) |
---|
69 | return |
---|
70 | |
---|
71 | def test_base(self): |
---|
72 | # We cannot call the fundamental methods of a base in that case |
---|
73 | container = PaymentsContainer() |
---|
74 | self.assertRaises( |
---|
75 | NotImplementedError, container.archive) |
---|
76 | self.assertRaises( |
---|
77 | NotImplementedError, container.clear) |
---|