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

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

Further increase overall test coverage.

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