1 | # -*- coding: utf-8 -*- |
---|
2 | import grok |
---|
3 | from waeup.kofa.testing import FunctionalTestCase |
---|
4 | from hurry.workflow.interfaces import IWorkflowState |
---|
5 | from zope.component import getUtility, createObject |
---|
6 | from waeup.kofa.students.interfaces import IStudentsUtils |
---|
7 | from waeup.kofa.students.tests.test_browser import StudentsFullSetup |
---|
8 | from waeup.fceokene.testing import FunctionalLayer |
---|
9 | |
---|
10 | class BedAllocationTests(StudentsFullSetup): |
---|
11 | |
---|
12 | layer = FunctionalLayer |
---|
13 | |
---|
14 | def test_getAccommodationDetails(self): |
---|
15 | students_utils = getUtility(IStudentsUtils) |
---|
16 | acc_details = students_utils.getAccommodationDetails(self.student) |
---|
17 | self.assertEqual(acc_details['bt'], 'ugft_male_fr') |
---|
18 | self.student['studycourse'].current_level = 200 |
---|
19 | self.certificate.study_mode = 'ug_pt' |
---|
20 | acc_details = students_utils.getAccommodationDetails(self.student) |
---|
21 | self.assertEqual(acc_details['bt'], 'regular_male_re') |
---|
22 | self.student['studycourse'].current_level = 300 |
---|
23 | acc_details = students_utils.getAccommodationDetails(self.student) |
---|
24 | self.assertEqual(acc_details['bt'], 'regular_male_fi') |
---|
25 | self.student['studycourse'].current_level = 400 |
---|
26 | acc_details = students_utils.getAccommodationDetails(self.student) |
---|
27 | self.assertEqual(acc_details['bt'], 'regular_male_fi') |
---|
28 | self.student['studycourse'].current_level = 500 |
---|
29 | acc_details = students_utils.getAccommodationDetails(self.student) |
---|
30 | self.assertEqual(acc_details['bt'], 'regular_male_fi') |
---|
31 | return |
---|
32 | |
---|
33 | def test_warnCreditsOOR(self): |
---|
34 | students_utils = getUtility(IStudentsUtils) |
---|
35 | studylevel = grok.Container() |
---|
36 | studylevel.total_credits_s1 = 17 |
---|
37 | studylevel.total_credits_s2 = 17 |
---|
38 | course = grok.Model() |
---|
39 | course.credits = 7 |
---|
40 | course.semester = 1 |
---|
41 | warning = students_utils.warnCreditsOOR(studylevel, course) |
---|
42 | self.assertEqual(warning, None) |
---|
43 | course.credits = 8 |
---|
44 | warning = students_utils.warnCreditsOOR(studylevel, course) |
---|
45 | self.assertEqual(warning, 'Maximum credits in 1st semester exceeded.') |
---|
46 | course.semester = 2 |
---|
47 | warning = students_utils.warnCreditsOOR(studylevel, course) |
---|
48 | self.assertEqual(warning, 'Maximum credits in 2nd semester exceeded.') |
---|
49 | warning = students_utils.warnCreditsOOR(studylevel) |
---|
50 | self.assertEqual(warning, 'Minimum credits in 1st semester not reached.') |
---|
51 | studylevel.total_credits_s1 = 18 |
---|
52 | warning = students_utils.warnCreditsOOR(studylevel) |
---|
53 | self.assertEqual(warning, 'Minimum credits in 2nd semester not reached.') |
---|
54 | return |
---|
55 | |
---|
56 | def test_set_payment_details(self): |
---|
57 | self.certificate.end_level = 300 |
---|
58 | self.student['studycourse'].current_verdict = 'B' |
---|
59 | self.student['studycourse'].current_level = 200 |
---|
60 | configuration = createObject('waeup.SessionConfiguration') |
---|
61 | configuration.academic_session = 2005 |
---|
62 | self.app['configuration'].addSessionConfiguration(configuration) |
---|
63 | self.app['configuration']['2005'].penalty_nce3_ft = 99.0 |
---|
64 | self.student['studycourse'].certificate.study_mode = 'nce_ft' |
---|
65 | utils = getUtility(IStudentsUtils) |
---|
66 | error, payment = utils.setPaymentDetails('schoolfee',self.student) |
---|
67 | IWorkflowState(self.student).setState('returning') |
---|
68 | error, payment = utils.setPaymentDetails('schoolfee',self.student) |
---|
69 | self.assertEqual(payment.amount_auth, 14124.0) # 13875 + 150 + 99 |
---|
70 | self.student['studycourse'].previous_verdict = 'O' |
---|
71 | error, payment = utils.setPaymentDetails('schoolfee',self.student) |
---|
72 | self.assertEqual(payment.amount_auth, 14025.0) # 13875 + 150 |
---|
73 | return |
---|