source: main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_student.py @ 7811

Last change on this file since 7811 was 7811, checked in by uli, 13 years ago

Rename all non-locales stuff from sirp to kofa.

  • Property svn:keywords set to Id
File size: 3.9 KB
Line 
1## $Id: test_student.py 7811 2012-03-08 19:00:51Z uli $
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.kofa.students.student import Student, StudentFactory
23from waeup.kofa.students.studycourse import StudentStudyCourse
24from waeup.kofa.students.studylevel import StudentStudyLevel, CourseTicket
25from waeup.kofa.students.payments import StudentPaymentsContainer
26from waeup.kofa.students.accommodation import StudentAccommodation, BedTicket
27from waeup.kofa.applicants.interfaces import IApplicantBaseData
28from waeup.kofa.students.interfaces import (
29    IStudent, IStudentStudyCourse, IStudentPaymentsContainer, IStudentAccommodation,
30    IStudentStudyLevel, ICourseTicket, IBedTicket)
31from waeup.kofa.testing import FunctionalLayer, FunctionalTestCase
32from waeup.kofa.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.student.firstname = u'Anna'
42        self.student.lastname = u'Tester'
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(IStudentStudyCourse, StudentStudyCourse)
59        verify.verifyObject(IStudentStudyCourse, self.studycourse)
60        verify.verifyObject(IStudentStudyLevel, self.studylevel)
61        verify.verifyObject(ICourseTicket, self.courseticket)
62        verify.verifyClass(IStudentPaymentsContainer, StudentPaymentsContainer)
63        verify.verifyObject(IStudentPaymentsContainer, self.payments)
64        verify.verifyClass(IStudentAccommodation, StudentAccommodation)
65        verify.verifyObject(IStudentAccommodation, self.accommodation)
66        verify.verifyClass(IBedTicket, BedTicket)
67        verify.verifyObject(IBedTicket, self.bedticket)
68        return
69
70    def test_base(self):
71        department = Department()
72        studycourse = StudentStudyCourse()
73        self.assertRaises(
74            TypeError, studycourse.addStudentStudyLevel, department)
75        studylevel = StudentStudyLevel()
76        self.assertRaises(
77            TypeError, studylevel.addCourseTicket, department)
78
79class StudentFactoryTest(FunctionalTestCase):
80
81    layer = FunctionalLayer
82
83    def setUp(self):
84        super(StudentFactoryTest, self).setUp()
85        self.factory = StudentFactory()
86
87    def tearDown(self):
88        super(StudentFactoryTest, self).tearDown()
89
90    def test_interfaces(self):
91        verify.verifyClass(IFactory, StudentFactory)
92        verify.verifyObject(IFactory, self.factory)
93
94    def test_factory(self):
95        obj = self.factory()
96        assert isinstance(obj, Student)
97
98    def test_getInterfaces(self):
99        implemented_by = self.factory.getInterfaces()
100        assert implemented_by.isOrExtends(IStudent)
Note: See TracBrowser for help on using the repository browser.