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 | """Tests for students and related. |
---|
17 | """ |
---|
18 | from zope.component.interfaces import IFactory |
---|
19 | from zope.interface import verify |
---|
20 | from waeup.sirp.students.student import Student, StudentFactory |
---|
21 | from waeup.sirp.students.studycourse import StudentStudyCourse |
---|
22 | from waeup.sirp.students.payments import StudentPayments |
---|
23 | from waeup.sirp.students.accommodation import StudentAccommodation |
---|
24 | from waeup.sirp.students.interfaces import ( |
---|
25 | IStudent, IStudentStudyCourse, IStudentPayments, IStudentAccommodation, |
---|
26 | ) |
---|
27 | from waeup.sirp.testing import FunctionalLayer, FunctionalTestCase |
---|
28 | |
---|
29 | class StudentTest(FunctionalTestCase): |
---|
30 | |
---|
31 | layer = FunctionalLayer |
---|
32 | |
---|
33 | def setUp(self): |
---|
34 | super(StudentTest, self).setUp() |
---|
35 | self.student = Student() |
---|
36 | self.studycourse = StudentStudyCourse() |
---|
37 | self.payments = StudentPayments() |
---|
38 | self.accommodation = StudentAccommodation() |
---|
39 | return |
---|
40 | |
---|
41 | def tearDown(self): |
---|
42 | super(StudentTest, self).tearDown() |
---|
43 | return |
---|
44 | |
---|
45 | def test_interfaces(self): |
---|
46 | verify.verifyClass(IStudent, Student) |
---|
47 | verify.verifyObject(IStudent, self.student) |
---|
48 | verify.verifyClass(IStudentStudyCourse, StudentStudyCourse) |
---|
49 | verify.verifyObject(IStudentStudyCourse, self.studycourse) |
---|
50 | verify.verifyClass(IStudentPayments, StudentPayments) |
---|
51 | verify.verifyObject(IStudentPayments, self.payments) |
---|
52 | verify.verifyClass(IStudentAccommodation, StudentAccommodation) |
---|
53 | verify.verifyObject(IStudentAccommodation, self.accommodation) |
---|
54 | return |
---|
55 | |
---|
56 | class StudentFactoryTest(FunctionalTestCase): |
---|
57 | |
---|
58 | layer = FunctionalLayer |
---|
59 | |
---|
60 | def setUp(self): |
---|
61 | super(StudentFactoryTest, self).setUp() |
---|
62 | self.factory = StudentFactory() |
---|
63 | |
---|
64 | def tearDown(self): |
---|
65 | super(StudentFactoryTest, self).tearDown() |
---|
66 | |
---|
67 | def test_interfaces(self): |
---|
68 | verify.verifyClass(IFactory, StudentFactory) |
---|
69 | verify.verifyObject(IFactory, self.factory) |
---|
70 | |
---|
71 | def test_factory(self): |
---|
72 | obj = self.factory() |
---|
73 | assert isinstance(obj, Student) |
---|
74 | |
---|
75 | def test_getInterfaces(self): |
---|
76 | implemented_by = self.factory.getInterfaces() |
---|
77 | assert implemented_by.isOrExtends(IStudent) |
---|