source: main/waeup.fceokene/trunk/src/waeup/fceokene/students/tests/test_utils.py @ 14556

Last change on this file since 14556 was 14556, checked in by Henrik Bettermann, 8 years ago

NCE repeaters don't have to pay penalty fee.

  • Property svn:keywords set to Id
File size: 3.0 KB
Line 
1# -*- coding: utf-8 -*-
2import grok
3from waeup.kofa.testing import FunctionalTestCase
4from hurry.workflow.interfaces import IWorkflowState
5from zope.component import getUtility, createObject
6from waeup.kofa.students.interfaces import IStudentsUtils
7from waeup.kofa.students.tests.test_browser import StudentsFullSetup
8from waeup.fceokene.testing import FunctionalLayer
9
10class 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_maxCreditsExceeded(self):
34        students_utils = getUtility(IStudentsUtils)
35        studylevel = grok.Container()
36        studylevel.total_credits = 40
37        course = grok.Model()
38        course.credits = 18
39        max_credits = students_utils.maxCreditsExceeded(studylevel, course)
40        self.assertEqual(max_credits, 0)
41        course.credits = 19
42        max_credits = students_utils.maxCreditsExceeded(studylevel, course)
43        self.assertEqual(max_credits, 58)
44        return
45
46    def test_set_payment_details(self):
47        self.certificate.end_level = 300
48        self.student['studycourse'].current_verdict = 'B'
49        self.student['studycourse'].current_level = 300
50        configuration = createObject('waeup.SessionConfiguration')
51        configuration.academic_session = 2005
52        self.app['configuration'].addSessionConfiguration(configuration)
53        self.app['configuration']['2005'].penalty_nce_ft = 99.0
54        self.student['studycourse'].certificate.study_mode = 'nce_ft'
55        utils = getUtility(IStudentsUtils)
56        error, payment = utils.setPaymentDetails('schoolfee',self.student)
57        IWorkflowState(self.student).setState('returning')
58        error, payment = utils.setPaymentDetails('schoolfee',self.student)
59        self.assertEqual(payment.amount_auth, 12224.0) # 11975 + 150 + 99
60        self.student['studycourse'].previous_verdict = 'O'
61        error, payment = utils.setPaymentDetails('schoolfee',self.student)
62        self.assertEqual(payment.amount_auth, 12125.0) # 11975 + 150
63        return
Note: See TracBrowser for help on using the repository browser.