source: main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_vocabularies.py @ 7637

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

It's quite tedious to setup the correct StudyLevelSource?. Now we have 2 probation levels and 3 spill-over levels. Pre-studies level (=10) can't be repeated.

  • Property svn:keywords set to Id
File size: 3.1 KB
Line 
1## $Id: test_vocabularies.py 7625 2012-02-10 20:05:55Z henrik $
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.sirp.students.vocabularies import StudyLevelSource
20from waeup.sirp.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        self.assertEqual(studylevelsource.getTitle(studycourse, None),
40            'Error: level id None out of range')
41        self.assertEqual(studylevelsource.getTitle(studycourse, 0),
42            'Error: level id 0 out of range')
43        self.assertEqual(studylevelsource.getTitle(studycourse, 10),
44            'Error: level id 10 out of range')
45        self.assertEqual(studylevelsource.getTitle(studycourse, 100),
46            '100 (Year 1)')
47        self.assertEqual(studylevelsource.getTitle(studycourse, 110),
48            '100 (Year 1) on 1st probation')
49        self.assertEqual(studylevelsource.getTitle(studycourse, 120),
50            '100 (Year 1) on 2nd probation')
51        self.assertEqual(studylevelsource.getTitle(studycourse, 500),
52            '500 (Year 5)')
53        self.assertEqual(studylevelsource.getTitle(studycourse, 600),
54            '500 (Year 5) 1st spillover')
55        self.assertEqual(studylevelsource.getTitle(studycourse, 610),
56            '500 (Year 5) 2nd spillover')
57        self.assertEqual(studylevelsource.getTitle(studycourse, 620),
58            '500 (Year 5) 3rd spillover')
59        self.assertEqual(studylevelsource.getTitle(studycourse, 630),
60            'Error: level id 630 out of range')
61        self.assertEqual(studylevelsource.getTitle(studycourse, 700),
62            'Error: level id 700 out of range')
63        # Now we change the certificates start_level to pre-studies
64        studycourse.certificate.start_level = 10
65        self.assertEqual(studylevelsource.getTitle(studycourse, 10),
66            'Pre-Studies')
67        # Repeating Pre-Studies level does not exist
68        self.assertRaises(KeyError,studylevelsource.getTitle,studycourse,20)
Note: See TracBrowser for help on using the repository browser.