## $Id: test_applicantcopier.py 9482 2012-10-31 08:25:49Z henrik $ ## ## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 2 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program; if not, write to the Free Software ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ## """ Tests for the creation of student containers with data from admitted applicants. """ import os import grok from datetime import datetime from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState from zope.event import notify from zope.component import getUtility from zope.i18n import translate from waeup.kofa.interfaces import IExtFileStore, IFileStoreNameChooser from waeup.kofa.applicants.tests.test_browser import ApplicantsFullSetup from kofacustom.nigeria.testing import FunctionalLayer session = datetime.now().year - 2 class ApplicantCopierFunctionalTests(ApplicantsFullSetup): layer = FunctionalLayer def setUp(self): super(ApplicantCopierFunctionalTests, self).setUp() return def test_copier_ume(self): IWorkflowState(self.applicant).setState('admitted') self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') self.browser.open(self.manage_path) self.fill_correct_values() self.browser.getControl("Save").click() self.browser.getControl(name="form.nationality").value = ['NG'] self.browser.getControl(name="form.course_admitted").value = ['CERT1'] self.browser.getControl("Save").click() (success, msg) = self.applicant.createStudent() student_id = translate(msg, 'waeup.kofa').split()[1] student = self.app['students'][student_id] self.assertEqual(student.state, 'admitted') # Has the ume student studycourse the correct attributes? self.assertEqual(student['studycourse'].certificate.code, 'CERT1') self.assertEqual(student['studycourse'].entry_session, session) self.assertEqual(student['studycourse'].entry_mode, 'ug_ft') self.assertEqual(student['studycourse'].current_session, session) self.assertEqual(student['studycourse'].current_level, 100) def test_copier_de(self): IWorkflowState(self.applicant).setState('admitted') # The applicant_id decides how studycourse attributes # are being set. self.applicant.applicant_id = u'pude2010_anything' self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') self.browser.open(self.manage_path) self.fill_correct_values() self.browser.getControl("Save").click() self.browser.getControl(name="form.nationality").value = ['NG'] self.browser.getControl(name="form.course_admitted").value = ['CERT1'] self.browser.getControl("Save").click() (success, msg) = self.applicant.createStudent() student_id = translate(msg, 'waeup.kofa').split()[1] student = self.app['students'][student_id] self.assertEqual(student.state, 'admitted') # Has the ume student studycourse the correct attributes? self.assertEqual(student['studycourse'].certificate.code, 'CERT1') self.assertEqual(student['studycourse'].entry_session, session) self.assertEqual(student['studycourse'].entry_mode, 'de_ft') self.assertEqual(student['studycourse'].current_session, session) self.assertEqual(student['studycourse'].current_level, 200)