source: main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_vocabularies.py @ 9131

Last change on this file since 9131 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.2 KB
Line 
1## $Id: test_vocabularies.py 7811 2012-03-08 19:00:51Z uli $
2##
3## Copyright (C) 2012 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##
18import unittest
19from waeup.kofa.students.vocabularies import StudyLevelSource
20from waeup.kofa.university.certificate import Certificate
21
22
23class FakeStudyCourse(object):
24
25    def __init__(self):
26        cert = Certificate(code="CERT1")
27        cert.start_level = 100
28        cert.end_level = 500
29        self.certificate = cert
30
31class VocabularyTests(unittest.TestCase):
32
33    def test_studylevelsource(self):
34        studycourse = FakeStudyCourse()
35        studylevelsource = StudyLevelSource().factory
36        values = studylevelsource.getValues(studycourse)
37        self.assertEqual(values, [100, 110, 120, 200, 210, 220, 300, 310, 320,
38            400, 410, 420, 500, 510, 520, 600, 610, 620])
39        # Unfortunately, unittests don't know about internationalization
40        self.assertEqual(studylevelsource.getTitle(studycourse, None),
41            'Error: level id ${value} out of range')
42        self.assertEqual(studylevelsource.getTitle(studycourse, 0),
43            'Error: level id ${value} out of range')
44        self.assertEqual(studylevelsource.getTitle(studycourse, 10),
45            'Error: level id ${value} out of range')
46        self.assertEqual(studylevelsource.getTitle(studycourse, 100),
47            '100 (Year 1)')
48        self.assertEqual(studylevelsource.getTitle(studycourse, 110),
49            '${title} on 1st probation')
50        self.assertEqual(studylevelsource.getTitle(studycourse, 120),
51            '${title} on 2nd probation')
52        self.assertEqual(studylevelsource.getTitle(studycourse, 500),
53            '500 (Year 5)')
54        self.assertEqual(studylevelsource.getTitle(studycourse, 600),
55            '${title} 1st spillover')
56        self.assertEqual(studylevelsource.getTitle(studycourse, 610),
57            '${title} 2nd spillover')
58        self.assertEqual(studylevelsource.getTitle(studycourse, 620),
59            '${title} 3rd spillover')
60        self.assertEqual(studylevelsource.getTitle(studycourse, 630),
61            'Error: level id ${value} out of range')
62        self.assertEqual(studylevelsource.getTitle(studycourse, 700),
63            'Error: level id ${value} out of range')
64        # Now we change the certificates start_level to pre-studies
65        studycourse.certificate.start_level = 10
66        self.assertEqual(studylevelsource.getTitle(studycourse, 10),
67            'Pre-Studies')
68        # Repeating Pre-Studies level does not exist
69        self.assertRaises(KeyError,studylevelsource.getTitle,studycourse,20)
Note: See TracBrowser for help on using the repository browser.