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

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

The StudentApplication? class is deprecated. We want to store the application_slip pdf file file instead.

Prepare everything in the students package for downloading such a pdf file.

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