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

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

Set up StudentApplication? class which implements IApplicantBaseData.

  • Property svn:keywords set to Id
File size: 4.1 KB
Line 
1## $Id: test_student.py 7339 2011-12-13 17:28:32Z 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.application import StudentApplication
24from waeup.sirp.students.studycourse import StudentStudyCourse
25from waeup.sirp.students.studylevel import StudentStudyLevel, CourseTicket
26from waeup.sirp.students.payments import StudentPaymentsContainer
27from waeup.sirp.students.accommodation import StudentAccommodation, BedTicket
28from waeup.sirp.applicants.interfaces import IApplicantBaseData
29from waeup.sirp.students.interfaces import (
30    IStudent, IStudentStudyCourse, IStudentPaymentsContainer, IStudentAccommodation,
31    IStudentStudyLevel, ICourseTicket, IBedTicket)
32from waeup.sirp.testing import FunctionalLayer, FunctionalTestCase
33from waeup.sirp.university.department import Department
34
35class StudentTest(FunctionalTestCase):
36
37    layer = FunctionalLayer
38
39    def setUp(self):
40        super(StudentTest, self).setUp()
41        self.student = Student()
42        self.application = StudentApplication()
43        self.studycourse = StudentStudyCourse()
44        self.studylevel = StudentStudyLevel()
45        self.courseticket = CourseTicket()
46        self.payments = StudentPaymentsContainer()
47        self.accommodation = StudentAccommodation()
48        self.bedticket = BedTicket()
49        return
50
51    def tearDown(self):
52        super(StudentTest, self).tearDown()
53        return
54
55    def test_interfaces(self):
56        verify.verifyClass(IStudent, Student)
57        verify.verifyObject(IStudent, self.student)
58        verify.verifyClass(IApplicantBaseData, StudentApplication)
59        verify.verifyObject(IApplicantBaseData, self.application)
60        verify.verifyClass(IStudentStudyCourse, StudentStudyCourse)
61        verify.verifyObject(IStudentStudyCourse, self.studycourse)
62        verify.verifyObject(IStudentStudyLevel, self.studylevel)
63        verify.verifyObject(ICourseTicket, self.courseticket)
64        verify.verifyClass(IStudentPaymentsContainer, StudentPaymentsContainer)
65        verify.verifyObject(IStudentPaymentsContainer, self.payments)
66        verify.verifyClass(IStudentAccommodation, StudentAccommodation)
67        verify.verifyObject(IStudentAccommodation, self.accommodation)
68        verify.verifyClass(IBedTicket, BedTicket)
69        verify.verifyObject(IBedTicket, self.bedticket)
70        return
71
72    def test_base(self):
73        department = Department()
74        studycourse = StudentStudyCourse()
75        self.assertRaises(
76            TypeError, studycourse.addStudentStudyLevel, department)
77        studylevel = StudentStudyLevel()
78        self.assertRaises(
79            TypeError, studylevel.addCourseTicket, department)
80
81class StudentFactoryTest(FunctionalTestCase):
82
83    layer = FunctionalLayer
84
85    def setUp(self):
86        super(StudentFactoryTest, self).setUp()
87        self.factory = StudentFactory()
88
89    def tearDown(self):
90        super(StudentFactoryTest, self).tearDown()
91
92    def test_interfaces(self):
93        verify.verifyClass(IFactory, StudentFactory)
94        verify.verifyObject(IFactory, self.factory)
95
96    def test_factory(self):
97        obj = self.factory()
98        assert isinstance(obj, Student)
99
100    def test_getInterfaces(self):
101        implemented_by = self.factory.getInterfaces()
102        assert implemented_by.isOrExtends(IStudent)
Note: See TracBrowser for help on using the repository browser.