source: main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_student.py @ 7269

Last change on this file since 7269 was 7193, checked in by Henrik Bettermann, 13 years ago

More copyright adjustments.

  • Property svn:keywords set to Id
File size: 3.8 KB
Line 
1## $Id: test_student.py 7193 2011-11-25 07:21:29Z henrik $
2##
3## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann
4## This program is free software; you can redistribute it and/or modify
5## it under the terms of the GNU General Public License as published by
6## the Free Software Foundation; either version 2 of the License, or
7## (at your option) any later version.
8##
9## This program is distributed in the hope that it will be useful,
10## but WITHOUT ANY WARRANTY; without even the implied warranty of
11## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12## GNU General Public License for more details.
13##
14## You should have received a copy of the GNU General Public License
15## along with this program; if not, write to the Free Software
16## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17##
18"""Tests for students and related.
19"""
20from zope.component.interfaces import IFactory
21from zope.interface import verify
22from waeup.sirp.students.student import Student, StudentFactory
23from waeup.sirp.students.studycourse import StudentStudyCourse
24from waeup.sirp.students.studylevel import StudentStudyLevel, CourseTicket
25from waeup.sirp.students.payments import StudentPaymentsContainer
26from waeup.sirp.students.accommodation import StudentAccommodation, BedTicket
27from waeup.sirp.students.interfaces import (
28    IStudent, IStudentStudyCourse, IStudentPaymentsContainer, IStudentAccommodation,
29    IStudentStudyLevel, ICourseTicket, IBedTicket)
30from waeup.sirp.testing import FunctionalLayer, FunctionalTestCase
31from waeup.sirp.university.department import Department
32
33class StudentTest(FunctionalTestCase):
34
35    layer = FunctionalLayer
36
37    def setUp(self):
38        super(StudentTest, self).setUp()
39        self.student = Student()
40        self.studycourse = StudentStudyCourse()
41        self.studylevel = StudentStudyLevel()
42        self.courseticket = CourseTicket()
43        self.payments = StudentPaymentsContainer()
44        self.accommodation = StudentAccommodation()
45        self.bedticket = BedTicket()
46        return
47
48    def tearDown(self):
49        super(StudentTest, self).tearDown()
50        return
51
52    def test_interfaces(self):
53        verify.verifyClass(IStudent, Student)
54        verify.verifyObject(IStudent, self.student)
55        verify.verifyClass(IStudentStudyCourse, StudentStudyCourse)
56        verify.verifyObject(IStudentStudyCourse, self.studycourse)
57        verify.verifyObject(IStudentStudyLevel, self.studylevel)
58        verify.verifyObject(ICourseTicket, self.courseticket)
59        verify.verifyClass(IStudentPaymentsContainer, StudentPaymentsContainer)
60        verify.verifyObject(IStudentPaymentsContainer, self.payments)
61        verify.verifyClass(IStudentAccommodation, StudentAccommodation)
62        verify.verifyObject(IStudentAccommodation, self.accommodation)
63        verify.verifyClass(IBedTicket, BedTicket)
64        verify.verifyObject(IBedTicket, self.bedticket)
65        return
66
67    def test_base(self):
68        department = Department()
69        studycourse = StudentStudyCourse()
70        self.assertRaises(
71            TypeError, studycourse.addStudentStudyLevel, department)
72        studylevel = StudentStudyLevel()
73        self.assertRaises(
74            TypeError, studylevel.addCourseTicket, department)
75
76class StudentFactoryTest(FunctionalTestCase):
77
78    layer = FunctionalLayer
79
80    def setUp(self):
81        super(StudentFactoryTest, self).setUp()
82        self.factory = StudentFactory()
83
84    def tearDown(self):
85        super(StudentFactoryTest, self).tearDown()
86
87    def test_interfaces(self):
88        verify.verifyClass(IFactory, StudentFactory)
89        verify.verifyObject(IFactory, self.factory)
90
91    def test_factory(self):
92        obj = self.factory()
93        assert isinstance(obj, Student)
94
95    def test_getInterfaces(self):
96        implemented_by = self.factory.getInterfaces()
97        assert implemented_by.isOrExtends(IStudent)
Note: See TracBrowser for help on using the repository browser.