source: main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/applicants/tests/test_applicantcopier.py @ 14587

Last change on this file since 14587 was 9482, checked in by Henrik Bettermann, 12 years ago

Customize _setStudyCourseAttributes. DE students start in level 200 and their entry mode is different from the certificates study mode.

  • Property svn:keywords set to Id
File size: 3.8 KB
Line 
1## $Id: test_applicantcopier.py 9482 2012-10-31 08:25:49Z henrik $
2##
3## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann
4## This program is free software; you can redistribute it and/or modify
5## it under the terms of the GNU General Public License as published by
6## the Free Software Foundation; either version 2 of the License, or
7## (at your option) any later version.
8##
9## This program is distributed in the hope that it will be useful,
10## but WITHOUT ANY WARRANTY; without even the implied warranty of
11## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12## GNU General Public License for more details.
13##
14## You should have received a copy of the GNU General Public License
15## along with this program; if not, write to the Free Software
16## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17##
18"""
19Tests for the creation of student containers with data from admitted applicants.
20"""
21import os
22import grok
23from datetime import datetime
24from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState
25from zope.event import notify
26from zope.component import getUtility
27from zope.i18n import translate
28from waeup.kofa.interfaces import IExtFileStore, IFileStoreNameChooser
29from waeup.kofa.applicants.tests.test_browser import ApplicantsFullSetup
30from kofacustom.nigeria.testing import FunctionalLayer
31
32session = datetime.now().year - 2
33
34class ApplicantCopierFunctionalTests(ApplicantsFullSetup):
35
36    layer = FunctionalLayer
37
38    def setUp(self):
39        super(ApplicantCopierFunctionalTests, self).setUp()
40        return
41
42    def test_copier_ume(self):
43        IWorkflowState(self.applicant).setState('admitted')
44        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
45        self.browser.open(self.manage_path)
46        self.fill_correct_values()
47        self.browser.getControl("Save").click()
48        self.browser.getControl(name="form.nationality").value = ['NG']
49        self.browser.getControl(name="form.course_admitted").value = ['CERT1']
50        self.browser.getControl("Save").click()
51        (success, msg) = self.applicant.createStudent()
52        student_id = translate(msg, 'waeup.kofa').split()[1]
53        student = self.app['students'][student_id]
54        self.assertEqual(student.state, 'admitted')
55        # Has the ume student studycourse the correct attributes?
56        self.assertEqual(student['studycourse'].certificate.code, 'CERT1')
57        self.assertEqual(student['studycourse'].entry_session, session)
58        self.assertEqual(student['studycourse'].entry_mode, 'ug_ft')
59        self.assertEqual(student['studycourse'].current_session, session)
60        self.assertEqual(student['studycourse'].current_level, 100)
61
62    def test_copier_de(self):
63        IWorkflowState(self.applicant).setState('admitted')
64        # The applicant_id decides how studycourse attributes
65        # are being set.
66        self.applicant.applicant_id = u'pude2010_anything'
67        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
68        self.browser.open(self.manage_path)
69        self.fill_correct_values()
70        self.browser.getControl("Save").click()
71        self.browser.getControl(name="form.nationality").value = ['NG']
72        self.browser.getControl(name="form.course_admitted").value = ['CERT1']
73        self.browser.getControl("Save").click()
74        (success, msg) = self.applicant.createStudent()
75        student_id = translate(msg, 'waeup.kofa').split()[1]
76        student = self.app['students'][student_id]
77        self.assertEqual(student.state, 'admitted')
78        # Has the ume student studycourse the correct attributes?
79        self.assertEqual(student['studycourse'].certificate.code, 'CERT1')
80        self.assertEqual(student['studycourse'].entry_session, session)
81        self.assertEqual(student['studycourse'].entry_mode, 'de_ft')
82        self.assertEqual(student['studycourse'].current_session, session)
83        self.assertEqual(student['studycourse'].current_level, 200)
Note: See TracBrowser for help on using the repository browser.