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

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

Repeaters can register less credits.

  • Property svn:keywords set to Id
File size: 4.3 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 StudentsUtilsTests(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 disabled_test_warnCreditsOOR_semester_exceeded(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_warnCreditsOOR(self):
57        students_utils = getUtility(IStudentsUtils)
58        studylevel = grok.Container()
59        studylevel.total_credits = 45
60        studylevel.__parent__ = self.student['studycourse']
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
73    def test_set_payment_details(self):
74        self.certificate.end_level = 300
75        self.student['studycourse'].current_verdict = 'B'
76        self.student['studycourse'].current_level = 200
77        configuration = createObject('waeup.SessionConfiguration')
78        configuration.academic_session = 2005
79        self.app['configuration'].addSessionConfiguration(configuration)
80        self.app['configuration']['2005'].penalty_nce3_ft = 99.0
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)
86        self.assertEqual(payment.amount_auth, 14124.0) # 13875 + 150 + 99
87        self.student['studycourse'].previous_verdict = 'O'
88        error, payment = utils.setPaymentDetails('schoolfee',self.student)
89        self.assertEqual(payment.amount_auth, 14025.0) # 13875 + 150
90        return
Note: See TracBrowser for help on using the repository browser.