1 | # -*- coding: utf-8 -*- |
---|
2 | from hurry.workflow.interfaces import IWorkflowState |
---|
3 | from zope.component import getUtility |
---|
4 | from waeup.kofa.testing import FunctionalTestCase |
---|
5 | from waeup.kofa.university.faculty import Faculty |
---|
6 | from waeup.kofa.university.department import Department |
---|
7 | from waeup.kofa.students.interfaces import IStudentsUtils |
---|
8 | from waeup.kofa.students.tests.test_browser import StudentsFullSetup |
---|
9 | from waeup.kwarapoly.testing import FunctionalLayer |
---|
10 | |
---|
11 | class StudentsUtilsTests(StudentsFullSetup): |
---|
12 | |
---|
13 | layer = FunctionalLayer |
---|
14 | |
---|
15 | def test_getAccommodationDetails(self): |
---|
16 | students_utils = getUtility(IStudentsUtils) |
---|
17 | acc_details = students_utils.getAccommodationDetails(self.student) |
---|
18 | self.assertEqual(acc_details['bt'], 'regular_male_fr') |
---|
19 | |
---|
20 | self.student['studycourse'].current_level = 200 |
---|
21 | acc_details = students_utils.getAccommodationDetails(self.student) |
---|
22 | self.assertEqual(acc_details['bt'], 'regular_male_re') |
---|
23 | |
---|
24 | self.student['studycourse'].current_level = 210 |
---|
25 | acc_details = students_utils.getAccommodationDetails(self.student) |
---|
26 | self.assertEqual(acc_details['bt'], 'regular_male_re') |
---|
27 | |
---|
28 | self.student['studycourse'].current_level = 300 |
---|
29 | acc_details = students_utils.getAccommodationDetails(self.student) |
---|
30 | self.assertEqual(acc_details['bt'], 'regular_male_fi') |
---|
31 | |
---|
32 | self.student['studycourse'].current_level = 400 |
---|
33 | acc_details = students_utils.getAccommodationDetails(self.student) |
---|
34 | self.assertEqual(acc_details['bt'], 'regular_male_fr') |
---|
35 | |
---|
36 | self.student['studycourse'].current_level = 500 |
---|
37 | acc_details = students_utils.getAccommodationDetails(self.student) |
---|
38 | self.assertEqual(acc_details['bt'], 'regular_male_re') |
---|
39 | |
---|
40 | self.student['studycourse'].current_level = 510 |
---|
41 | acc_details = students_utils.getAccommodationDetails(self.student) |
---|
42 | self.assertEqual(acc_details['bt'], 'regular_male_re') |
---|
43 | |
---|
44 | self.student['studycourse'].current_level = 600 |
---|
45 | acc_details = students_utils.getAccommodationDetails(self.student) |
---|
46 | self.assertEqual(acc_details['bt'], 'regular_male_fi') |
---|
47 | return |
---|
48 | |
---|
49 | def test_setMatricNumber(self): |
---|
50 | utils = getUtility(IStudentsUtils) |
---|
51 | self.student.matric_number = None |
---|
52 | msg, mnumber = utils.setMatricNumber(self.student) |
---|
53 | self.assertEqual(msg, 'Available from session 2015/2016') |
---|
54 | self.student['studycourse'].entry_mode = 'nd_ft' |
---|
55 | self.student['studycourse'].entry_session = 2015 |
---|
56 | msg, mnumber = utils.setMatricNumber(self.student) |
---|
57 | self.assertEqual(mnumber, None) |
---|
58 | self.assertEqual(msg, 'Wrong state.') |
---|
59 | IWorkflowState(self.student).setState('school fee paid') |
---|
60 | msg, mnumber = utils.setMatricNumber(self.student) |
---|
61 | self.assertEqual(self.student.matric_number, 'ND/15/dep1/FT/001') |
---|
62 | self.assertEqual( |
---|
63 | self.app['faculties']['fac1']['dep1'].next_matric_dict, |
---|
64 | {2015: 2}) |
---|
65 | # setting a new matric number in 2016, extends next_matric_dict |
---|
66 | self.student['studycourse'].entry_session = 2016 |
---|
67 | self.student.matric_number = None |
---|
68 | msg, mnumber = utils.setMatricNumber(self.student) |
---|
69 | self.assertEqual( |
---|
70 | self.app['faculties']['fac1']['dep1'].next_matric_dict, |
---|
71 | {2015: 2, 2016: 2}) |
---|
72 | # setting a new matric number in 2014 again, increases the counter |
---|
73 | self.student.matric_number = None |
---|
74 | msg, mnumber = utils.setMatricNumber(self.student) |
---|
75 | self.assertEqual( |
---|
76 | self.app['faculties']['fac1']['dep1'].next_matric_dict, |
---|
77 | {2015: 2, 2016: 3}) |
---|
78 | # matric number must not exist |
---|
79 | msg, mnumber = utils.setMatricNumber(self.student) |
---|
80 | self.assertEqual(msg, 'Matriculation number already set.') |
---|
81 | # certificate must be set. |
---|
82 | self.student.matric_number = None |
---|
83 | self.student['studycourse'].certificate = None |
---|
84 | msg, mnumber = utils.setMatricNumber(self.student) |
---|
85 | self.assertEqual(msg, 'No certificate assigned.') |
---|
86 | return |
---|