source: main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/students/tests/test_utils.py @ 13606

Last change on this file since 13606 was 13535, checked in by Henrik Bettermann, 9 years ago

Implement new matric number construction method.

Temporarily deactivate the method.

  • Property svn:keywords set to Id
File size: 4.1 KB
Line 
1# -*- coding: utf-8 -*-
2from hurry.workflow.interfaces import IWorkflowState
3from zope.component import getUtility
4from waeup.kofa.testing import FunctionalTestCase
5from waeup.kofa.university.faculty import Faculty
6from waeup.kofa.university.department import Department
7from waeup.kofa.students.student import Student
8from waeup.kofa.students.interfaces import IStudentsUtils
9from waeup.kofa.students.tests.test_browser import StudentsFullSetup
10from waeup.kwarapoly.testing import FunctionalLayer
11
12class StudentsUtilsTests(StudentsFullSetup):
13
14    layer = FunctionalLayer
15
16    def test_getAccommodationDetails(self):
17        students_utils = getUtility(IStudentsUtils)
18        acc_details  = students_utils.getAccommodationDetails(self.student)
19        self.assertEqual(acc_details['bt'], 'regular_male_fr')
20
21        self.student['studycourse'].current_level = 200
22        acc_details  = students_utils.getAccommodationDetails(self.student)
23        self.assertEqual(acc_details['bt'], 'regular_male_re')
24
25        self.student['studycourse'].current_level = 210
26        acc_details  = students_utils.getAccommodationDetails(self.student)
27        self.assertEqual(acc_details['bt'], 'regular_male_re')
28
29        self.student['studycourse'].current_level = 300
30        acc_details  = students_utils.getAccommodationDetails(self.student)
31        self.assertEqual(acc_details['bt'], 'regular_male_fi')
32
33        self.student['studycourse'].current_level = 400
34        acc_details  = students_utils.getAccommodationDetails(self.student)
35        self.assertEqual(acc_details['bt'], 'regular_male_fr')
36
37        self.student['studycourse'].current_level = 500
38        acc_details  = students_utils.getAccommodationDetails(self.student)
39        self.assertEqual(acc_details['bt'], 'regular_male_re')
40
41        self.student['studycourse'].current_level = 510
42        acc_details  = students_utils.getAccommodationDetails(self.student)
43        self.assertEqual(acc_details['bt'], 'regular_male_re')
44
45        self.student['studycourse'].current_level = 600
46        acc_details  = students_utils.getAccommodationDetails(self.student)
47        self.assertEqual(acc_details['bt'], 'regular_male_fi')
48        return
49
50    def test_setMatricNumber(self):
51        # Add second student
52        secondstudent = Student()
53        secondstudent.firstname = u'second'
54        secondstudent.lastname = u'Student'
55        self.app['students'].addStudent(secondstudent)
56        student_id = secondstudent.student_id
57        secondstudent['studycourse'].certificate = self.certificate
58        secondstudent['studycourse'].entry_session = 2015
59        secondstudent['studycourse'].entry_mode = 'nd_ft'
60        IWorkflowState(secondstudent).setState('school fee paid')
61        utils = getUtility(IStudentsUtils)
62        self.student.matric_number = None
63        msg, mnumber = utils.setMatricNumber(self.student)
64        self.assertEqual(msg, 'Available from session 2015/2016')
65        self.student['studycourse'].entry_mode = 'nd_ft'
66        self.student['studycourse'].entry_session = 2015
67        msg, mnumber = utils.setMatricNumber(self.student)
68        self.assertEqual(mnumber, None)
69        self.assertEqual(msg, 'Wrong state.')
70        IWorkflowState(self.student).setState('school fee paid')
71        msg, mnumber = utils.setMatricNumber(self.student)
72        self.assertEqual(self.student.matric_number, 'ND/15/dep1/FT/001')
73        msg, mnumber = utils.setMatricNumber(self.student)
74        self.assertEqual(msg, 'Matriculation number already set.')
75        # Second student gets nex matric number
76        msg, mnumber = utils.setMatricNumber(secondstudent)
77        self.assertEqual(secondstudent.matric_number, 'ND/15/dep1/FT/002')
78        self.student.matric_number = u'ND/15/dep1/FT/011'
79        secondstudent.matric_number = None
80        msg, mnumber = utils.setMatricNumber(secondstudent)
81        self.assertEqual(secondstudent.matric_number, 'ND/15/dep1/FT/012')
82        # Certificate must be set.
83        self.student.matric_number = None
84        self.student['studycourse'].certificate = None
85        msg, mnumber = utils.setMatricNumber(self.student)
86        self.assertEqual(msg, 'No certificate assigned.')
87        return
Note: See TracBrowser for help on using the repository browser.