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

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

Store utc without tzinfo in persistent datetime objects. Localisation will be done in views only.

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