[9207] | 1 | # -*- coding: utf-8 -*- |
---|
[9903] | 2 | import grok |
---|
[9207] | 3 | from waeup.kofa.testing import FunctionalTestCase |
---|
[14556] | 4 | from hurry.workflow.interfaces import IWorkflowState |
---|
| 5 | from zope.component import getUtility, createObject |
---|
[9207] | 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 | |
---|
[14618] | 10 | class StudentsUtilsTests(StudentsFullSetup): |
---|
[9207] | 11 | |
---|
| 12 | layer = FunctionalLayer |
---|
| 13 | |
---|
| 14 | def test_getAccommodationDetails(self): |
---|
| 15 | students_utils = getUtility(IStudentsUtils) |
---|
| 16 | acc_details = students_utils.getAccommodationDetails(self.student) |
---|
[13614] | 17 | self.assertEqual(acc_details['bt'], 'ugft_male_fr') |
---|
[9207] | 18 | self.student['studycourse'].current_level = 200 |
---|
[13614] | 19 | self.certificate.study_mode = 'ug_pt' |
---|
[9207] | 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') |
---|
[9903] | 31 | return |
---|
| 32 | |
---|
[14617] | 33 | def disabled_test_warnCreditsOOR_semester_exceeded(self): |
---|
[9903] | 34 | students_utils = getUtility(IStudentsUtils) |
---|
| 35 | studylevel = grok.Container() |
---|
[14591] | 36 | studylevel.total_credits_s1 = 17 |
---|
| 37 | studylevel.total_credits_s2 = 17 |
---|
[9903] | 38 | course = grok.Model() |
---|
[14591] | 39 | course.credits = 7 |
---|
| 40 | course.semester = 1 |
---|
[14586] | 41 | warning = students_utils.warnCreditsOOR(studylevel, course) |
---|
| 42 | self.assertEqual(warning, None) |
---|
[14591] | 43 | course.credits = 8 |
---|
[14586] | 44 | warning = students_utils.warnCreditsOOR(studylevel, course) |
---|
[14591] | 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.') |
---|
[14556] | 54 | return |
---|
| 55 | |
---|
[14617] | 56 | def test_warnCreditsOOR(self): |
---|
| 57 | students_utils = getUtility(IStudentsUtils) |
---|
| 58 | studylevel = grok.Container() |
---|
| 59 | studylevel.total_credits = 45 |
---|
[14618] | 60 | studylevel.__parent__ = self.student['studycourse'] |
---|
[14617] | 61 | course = grok.Model() |
---|
| 62 | course.credits = 7 |
---|
| 63 | warning = students_utils.warnCreditsOOR(studylevel, course) |
---|
| 64 | self.assertEqual(warning, None) |
---|
| 65 | course.credits = 8 |
---|
| 66 | warning = students_utils.warnCreditsOOR(studylevel, course) |
---|
| 67 | self.assertEqual(warning, 'Maximum credits exceeded.') |
---|
| 68 | studylevel.total_credits_s1 = 17 |
---|
| 69 | warning = students_utils.warnCreditsOOR(studylevel) |
---|
| 70 | self.assertEqual(warning, 'Minimum credits in 1st semester not reached.') |
---|
| 71 | return |
---|
| 72 | |
---|
[14556] | 73 | def test_set_payment_details(self): |
---|
| 74 | self.certificate.end_level = 300 |
---|
| 75 | self.student['studycourse'].current_verdict = 'B' |
---|
[14566] | 76 | self.student['studycourse'].current_level = 200 |
---|
[14556] | 77 | configuration = createObject('waeup.SessionConfiguration') |
---|
| 78 | configuration.academic_session = 2005 |
---|
| 79 | self.app['configuration'].addSessionConfiguration(configuration) |
---|
[14566] | 80 | self.app['configuration']['2005'].penalty_nce3_ft = 99.0 |
---|
[14556] | 81 | self.student['studycourse'].certificate.study_mode = 'nce_ft' |
---|
| 82 | utils = getUtility(IStudentsUtils) |
---|
| 83 | error, payment = utils.setPaymentDetails('schoolfee',self.student) |
---|
| 84 | IWorkflowState(self.student).setState('returning') |
---|
| 85 | error, payment = utils.setPaymentDetails('schoolfee',self.student) |
---|
[15594] | 86 | self.assertEqual(payment.amount_auth, 15974) # 15875 + 99 |
---|
[14556] | 87 | self.student['studycourse'].previous_verdict = 'O' |
---|
| 88 | error, payment = utils.setPaymentDetails('schoolfee',self.student) |
---|
[15594] | 89 | self.assertEqual(payment.amount_auth, 15875) |
---|
[14556] | 90 | return |
---|