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'], 'ugft_male_fr') |
---|
17 | self.student['studycourse'].current_level = 200 |
---|
18 | self.certificate.study_mode = 'ug_pt' |
---|
19 | acc_details = students_utils.getAccommodationDetails(self.student) |
---|
20 | self.assertEqual(acc_details['bt'], 'regular_male_re') |
---|
21 | self.student['studycourse'].current_level = 300 |
---|
22 | acc_details = students_utils.getAccommodationDetails(self.student) |
---|
23 | self.assertEqual(acc_details['bt'], 'regular_male_fi') |
---|
24 | self.student['studycourse'].current_level = 400 |
---|
25 | acc_details = students_utils.getAccommodationDetails(self.student) |
---|
26 | self.assertEqual(acc_details['bt'], 'regular_male_fi') |
---|
27 | self.student['studycourse'].current_level = 500 |
---|
28 | acc_details = students_utils.getAccommodationDetails(self.student) |
---|
29 | self.assertEqual(acc_details['bt'], 'regular_male_fi') |
---|
30 | return |
---|
31 | |
---|
32 | def test_maxCreditsExceeded(self): |
---|
33 | students_utils = getUtility(IStudentsUtils) |
---|
34 | studylevel = grok.Container() |
---|
35 | studylevel.total_credits = 40 |
---|
36 | course = grok.Model() |
---|
37 | course.credits = 18 |
---|
38 | max_credits = students_utils.maxCreditsExceeded(studylevel, course) |
---|
39 | self.assertEqual(max_credits, 0) |
---|
40 | course.credits = 19 |
---|
41 | max_credits = students_utils.maxCreditsExceeded(studylevel, course) |
---|
42 | self.assertEqual(max_credits, 58) |
---|