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

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

Add unit test for StudyLevelSource?.

  • Property svn:keywords set to Id
File size: 2.7 KB
Line 
1## $Id: test_vocabularies.py 7616 2012-02-09 08:02:40Z 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])
39        self.assertTrue(studylevelsource.getTitle(studycourse, 0),
40            'Error: level id 0 out of range')
41        self.assertTrue(studylevelsource.getTitle(studycourse, 10),
42            'Error: level id 10 out of range')
43        self.assertTrue(studylevelsource.getTitle(studycourse, 100),
44            '100 (Year 1)')
45        self.assertTrue(studylevelsource.getTitle(studycourse, 110),
46            '100 (Year 1) on 1. probation')
47        self.assertTrue(studylevelsource.getTitle(studycourse, 120),
48            '100 (Year 1) on 2. probation')
49        self.assertTrue(studylevelsource.getTitle(studycourse, 500),
50            '500 (Year 5)')
51        self.assertTrue(studylevelsource.getTitle(studycourse, 600),
52            '500 (Year 5) spillover')
53        self.assertTrue(studylevelsource.getTitle(studycourse, 610),
54            '500 (Year 5) 2nd spillover')
55        self.assertTrue(studylevelsource.getTitle(studycourse, 620),
56            'Error: level id 620 out of range')
57        self.assertTrue(studylevelsource.getTitle(studycourse, 900),
58            'Error: level id 900 out of range')
59        # Now we change the certificates start_level in order to include
60        # pre-studies
61        studycourse.certificate.start_level = 10
62        self.assertTrue(studylevelsource.getTitle(studycourse, 10),
63            'Pre-Studies')
Note: See TracBrowser for help on using the repository browser.