source: main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/students/tests/test_student.py @ 12108

Last change on this file since 12108 was 8968, checked in by Henrik Bettermann, 12 years ago

Add is_foreigner property.

  • Property svn:keywords set to Id
File size: 4.8 KB
Line 
1## $Id: test_student.py 8968 2012-07-10 09:26:36Z 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 zope.schema.interfaces import ConstraintNotSatisfied
24from waeup.kofa.testing import FunctionalTestCase
25from kofacustom.nigeria.students.student import NigeriaStudent, NigeriaStudentFactory
26from kofacustom.nigeria.students.studycourse import (
27    NigeriaStudentStudyCourse, NigeriaStudentStudyCourseFactory)
28from kofacustom.nigeria.students.studylevel import (
29    NigeriaStudentStudyLevel, NigeriaCourseTicket,
30    NigeriaStudentStudyLevelFactory,
31    NigeriaCourseTicketFactory)
32from kofacustom.nigeria.students.interfaces import (
33    INigeriaStudent, INigeriaStudentStudyCourse,
34    INigeriaStudentStudyLevel, INigeriaCourseTicket)
35from kofacustom.nigeria.testing import FunctionalLayer
36
37
38class NigeriaStudentFactoryTest(FunctionalTestCase):
39
40    layer = FunctionalLayer
41
42    def setUp(self):
43        super(NigeriaStudentFactoryTest, self).setUp()
44        self.factory = NigeriaStudentFactory()
45
46    def tearDown(self):
47        super(NigeriaStudentFactoryTest, self).tearDown()
48
49    def test_interfaces(self):
50        verify.verifyClass(IFactory, NigeriaStudentFactory)
51        verify.verifyObject(IFactory, self.factory)
52
53    def test_factory(self):
54        obj = self.factory()
55        assert isinstance(obj, NigeriaStudent)
56
57    def test_getInterfaces(self):
58        implemented_by = self.factory.getInterfaces()
59        assert implemented_by.isOrExtends(INigeriaStudent)
60
61    def test_is_foreigner(self):
62        student = self.factory()
63        self.assertRaises(
64            ConstraintNotSatisfied, setattr, student, 'nationality', 'XX')
65        student.nationality = 'NG'
66        self.assertFalse(student.is_foreigner)
67        student.nationality = 'DE'
68        self.assertTrue(student.is_foreigner)
69
70class NigeriaStudentStudyCourseFactoryTest(FunctionalTestCase):
71
72    layer = FunctionalLayer
73
74    def setUp(self):
75        super(NigeriaStudentStudyCourseFactoryTest, self).setUp()
76        self.factory = NigeriaStudentStudyCourseFactory()
77
78    def tearDown(self):
79        super(NigeriaStudentStudyCourseFactoryTest, self).tearDown()
80
81    def test_interfaces(self):
82        verify.verifyClass(IFactory, NigeriaStudentStudyCourseFactory)
83        verify.verifyObject(IFactory, self.factory)
84
85    def test_factory(self):
86        obj = self.factory()
87        assert isinstance(obj, NigeriaStudentStudyCourse)
88
89    def test_getInterfaces(self):
90        implemented_by = self.factory.getInterfaces()
91        assert implemented_by.isOrExtends(INigeriaStudentStudyCourse)
92
93class NigeriaStudentStudyLevelFactoryTest(FunctionalTestCase):
94
95    layer = FunctionalLayer
96
97    def setUp(self):
98        super(NigeriaStudentStudyLevelFactoryTest, self).setUp()
99        self.factory = NigeriaStudentStudyLevelFactory()
100
101    def tearDown(self):
102        super(NigeriaStudentStudyLevelFactoryTest, self).tearDown()
103
104    def test_interfaces(self):
105        verify.verifyClass(IFactory, NigeriaStudentStudyLevelFactory)
106        verify.verifyObject(IFactory, self.factory)
107
108    def test_factory(self):
109        obj = self.factory()
110        assert isinstance(obj, NigeriaStudentStudyLevel)
111
112    def test_getInterfaces(self):
113        implemented_by = self.factory.getInterfaces()
114        assert implemented_by.isOrExtends(INigeriaStudentStudyLevel)
115
116class NigeriaCourseTicketFactoryTest(FunctionalTestCase):
117
118    layer = FunctionalLayer
119
120    def setUp(self):
121        super(NigeriaCourseTicketFactoryTest, self).setUp()
122        self.factory = NigeriaCourseTicketFactory()
123
124    def tearDown(self):
125        super(NigeriaCourseTicketFactoryTest, self).tearDown()
126
127    def test_interfaces(self):
128        verify.verifyClass(IFactory, NigeriaCourseTicketFactory)
129        verify.verifyObject(IFactory, self.factory)
130
131    def test_factory(self):
132        obj = self.factory()
133        assert isinstance(obj, NigeriaCourseTicket)
134
135    def test_getInterfaces(self):
136        implemented_by = self.factory.getInterfaces()
137        assert implemented_by.isOrExtends(INigeriaCourseTicket)
Note: See TracBrowser for help on using the repository browser.