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.students import ( |
---|
30 | Student, StudentFactory, |
---|
31 | ) |
---|
32 | from waeup.sirp.students.interfaces import ( |
---|
33 | IStudent, |
---|
34 | ) |
---|
35 | from waeup.sirp.testing import FunctionalLayer |
---|
36 | |
---|
37 | class StudentTest(FunctionalTestCase): |
---|
38 | |
---|
39 | layer = FunctionalLayer |
---|
40 | |
---|
41 | def setUp(self): |
---|
42 | super(StudentTest, self).setUp() |
---|
43 | self.student = Student() |
---|
44 | return |
---|
45 | |
---|
46 | def tearDown(self): |
---|
47 | super(StudentTest, self).tearDown() |
---|
48 | return |
---|
49 | |
---|
50 | def test_interfaces(self): |
---|
51 | verify.verifyClass(IStudent, Student) |
---|
52 | verify.verifyObject(IStudent, self.student) |
---|
53 | return |
---|
54 | |
---|
55 | class StudentFactoryTest(FunctionalTestCase): |
---|
56 | |
---|
57 | layer = FunctionalLayer |
---|
58 | |
---|
59 | def setUp(self): |
---|
60 | self.factory = StudentFactory() |
---|
61 | |
---|
62 | def tearDown(self): |
---|
63 | pass |
---|
64 | |
---|
65 | def test_interfaces(self): |
---|
66 | verify.verifyClass(IFactory, StudentFactory) |
---|
67 | verify.verifyObject(IFactory, self.factory) |
---|
68 | |
---|
69 | def test_factory(self): |
---|
70 | obj = self.factory() |
---|
71 | assert isinstance(obj, Student) |
---|
72 | |
---|
73 | def test_getInterfaces(self): |
---|
74 | implemented_by = self.factory.getInterfaces() |
---|
75 | assert implemented_by.isOrExtends(IStudent) |
---|