1 | # -*- coding: utf-8 -*- |
---|
2 | import grok |
---|
3 | from waeup.kofa.testing import FunctionalTestCase |
---|
4 | from zope.component import getUtility |
---|
5 | from waeup.kofa.students.interfaces import IStudentsUtils |
---|
6 | from waeup.kofa.students.tests.test_browser import StudentsFullSetup |
---|
7 | from waeup.fceokene.testing import FunctionalLayer |
---|
8 | |
---|
9 | class BedAllocationTests(StudentsFullSetup): |
---|
10 | |
---|
11 | layer = FunctionalLayer |
---|
12 | |
---|
13 | def test_getAccommodationDetails(self): |
---|
14 | students_utils = getUtility(IStudentsUtils) |
---|
15 | acc_details = students_utils.getAccommodationDetails(self.student) |
---|
16 | self.assertEqual(acc_details['bt'], 'regular_male_fr') |
---|
17 | self.student['studycourse'].current_level = 200 |
---|
18 | acc_details = students_utils.getAccommodationDetails(self.student) |
---|
19 | self.assertEqual(acc_details['bt'], 'regular_male_re') |
---|
20 | self.student['studycourse'].current_level = 300 |
---|
21 | acc_details = students_utils.getAccommodationDetails(self.student) |
---|
22 | self.assertEqual(acc_details['bt'], 'regular_male_fi') |
---|
23 | self.student['studycourse'].current_level = 400 |
---|
24 | acc_details = students_utils.getAccommodationDetails(self.student) |
---|
25 | self.assertEqual(acc_details['bt'], 'regular_male_fi') |
---|
26 | self.student['studycourse'].current_level = 500 |
---|
27 | acc_details = students_utils.getAccommodationDetails(self.student) |
---|
28 | self.assertEqual(acc_details['bt'], 'regular_male_fi') |
---|
29 | return |
---|
30 | |
---|
31 | def test_maxCreditsExceeded(self): |
---|
32 | students_utils = getUtility(IStudentsUtils) |
---|
33 | studylevel = grok.Container() |
---|
34 | studylevel.total_credits = 40 |
---|
35 | course = grok.Model() |
---|
36 | course.credits = 18 |
---|
37 | max_credits = students_utils.maxCreditsExceeded(studylevel, course) |
---|
38 | self.assertEqual(max_credits, 0) |
---|
39 | course.credits = 19 |
---|
40 | max_credits = students_utils.maxCreditsExceeded(studylevel, course) |
---|
41 | self.assertEqual(max_credits, 58) |
---|