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 | import unittest |
---|
19 | from StringIO import StringIO |
---|
20 | from zope.app.testing.functional import FunctionalTestCase |
---|
21 | from zope.component import ( |
---|
22 | provideAdapter, adapts, getGlobalSiteManager, provideUtility) |
---|
23 | from zope.component.hooks import setSite |
---|
24 | from zope.component.interfaces import IFactory |
---|
25 | from zope.interface import verify, implements |
---|
26 | from zope.location.interfaces import ILocation |
---|
27 | from zope.publisher.base import TestRequest |
---|
28 | from zope.publisher.interfaces import NotFound |
---|
29 | from waeup.sirp.students.student import ( |
---|
30 | Student, StudentFactory, |
---|
31 | ) |
---|
32 | from waeup.sirp.students.studycourse import StudentStudyCourse |
---|
33 | from waeup.sirp.students.payments import StudentPayments |
---|
34 | from waeup.sirp.students.accommodation import StudentAccommodation |
---|
35 | from waeup.sirp.students.interfaces import ( |
---|
36 | IStudent, IStudentStudyCourse, IStudentPayments, IStudentAccommodation, |
---|
37 | ) |
---|
38 | from waeup.sirp.testing import FunctionalLayer |
---|
39 | |
---|
40 | class StudentTest(FunctionalTestCase): |
---|
41 | |
---|
42 | layer = FunctionalLayer |
---|
43 | |
---|
44 | def setUp(self): |
---|
45 | super(StudentTest, self).setUp() |
---|
46 | self.student = Student() |
---|
47 | self.studycourse = StudentStudyCourse() |
---|
48 | self.payments = StudentPayments() |
---|
49 | self.accommodation = StudentAccommodation() |
---|
50 | return |
---|
51 | |
---|
52 | def tearDown(self): |
---|
53 | super(StudentTest, self).tearDown() |
---|
54 | return |
---|
55 | |
---|
56 | def test_interfaces(self): |
---|
57 | verify.verifyClass(IStudent, Student) |
---|
58 | verify.verifyObject(IStudent, self.student) |
---|
59 | verify.verifyClass(IStudentStudyCourse, StudentStudyCourse) |
---|
60 | verify.verifyObject(IStudentStudyCourse, self.studycourse) |
---|
61 | verify.verifyClass(IStudentPayments, StudentPayments) |
---|
62 | verify.verifyObject(IStudentPayments, self.payments) |
---|
63 | verify.verifyClass(IStudentAccommodation, StudentAccommodation) |
---|
64 | verify.verifyObject(IStudentAccommodation, self.accommodation) |
---|
65 | return |
---|
66 | |
---|
67 | class StudentFactoryTest(FunctionalTestCase): |
---|
68 | |
---|
69 | layer = FunctionalLayer |
---|
70 | |
---|
71 | def setUp(self): |
---|
72 | self.factory = StudentFactory() |
---|
73 | |
---|
74 | def tearDown(self): |
---|
75 | pass |
---|
76 | |
---|
77 | def test_interfaces(self): |
---|
78 | verify.verifyClass(IFactory, StudentFactory) |
---|
79 | verify.verifyObject(IFactory, self.factory) |
---|
80 | |
---|
81 | def test_factory(self): |
---|
82 | obj = self.factory() |
---|
83 | assert isinstance(obj, Student) |
---|
84 | |
---|
85 | def test_getInterfaces(self): |
---|
86 | implemented_by = self.factory.getInterfaces() |
---|
87 | assert implemented_by.isOrExtends(IStudent) |
---|