| 1 | ## $Id: test_applicantcopier.py 15455 2019-06-15 12:30:51Z 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 | """ |
|---|
| 19 | Tests for the creation of student containers with data from admitted applicants. |
|---|
| 20 | """ |
|---|
| 21 | import os |
|---|
| 22 | import grok |
|---|
| 23 | from datetime import datetime |
|---|
| 24 | from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState |
|---|
| 25 | from zope.event import notify |
|---|
| 26 | from zope.component import getUtility, createObject |
|---|
| 27 | from zope.i18n import translate |
|---|
| 28 | from waeup.kofa.interfaces import IExtFileStore, IFileStoreNameChooser |
|---|
| 29 | from waeup.kofa.applicants.tests.test_browser import ApplicantsFullSetup |
|---|
| 30 | from waeup.aaue.testing import FunctionalLayer |
|---|
| 31 | |
|---|
| 32 | session = datetime.now().year - 2 |
|---|
| 33 | |
|---|
| 34 | class ApplicantCopierFunctionalTests(ApplicantsFullSetup): |
|---|
| 35 | |
|---|
| 36 | layer = FunctionalLayer |
|---|
| 37 | |
|---|
| 38 | def setUp(self): |
|---|
| 39 | super(ApplicantCopierFunctionalTests, self).setUp() |
|---|
| 40 | certificate = createObject('waeup.Certificate') |
|---|
| 41 | certificate.code = 'CERT2' |
|---|
| 42 | certificate.title = 'New Certificate' |
|---|
| 43 | certificate.application_category = 'basic' |
|---|
| 44 | self.app['faculties']['fac1']['dep1'].certificates.addCertificate( |
|---|
| 45 | certificate) |
|---|
| 46 | return |
|---|
| 47 | |
|---|
| 48 | def test_copier(self): |
|---|
| 49 | IWorkflowState(self.applicant).setState('admitted') |
|---|
| 50 | self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') |
|---|
| 51 | self.browser.open(self.manage_path) |
|---|
| 52 | self.fill_correct_values() |
|---|
| 53 | self.browser.getControl("Save").click() |
|---|
| 54 | self.browser.getControl(name="form.course2").value = ['CERT2'] |
|---|
| 55 | self.browser.getControl(name="form.nationality").value = ['NG'] |
|---|
| 56 | self.browser.getControl(name="form.lga").value = ['abia_aba_north'] |
|---|
| 57 | self.browser.getControl(name="form.course_admitted").value = ['CERT1'] |
|---|
| 58 | #self.browser.getControl(name="form.programme_type").value = ['regular'] |
|---|
| 59 | # Date of birth is not required |
|---|
| 60 | self.browser.getControl(name="form.date_of_birth").value = '' |
|---|
| 61 | |
|---|
| 62 | self.browser.getControl(name="form.fst_sit_fname").value = 'Alfons' |
|---|
| 63 | self.browser.getControl(name="form.fst_sit_no").value = '123' |
|---|
| 64 | self.browser.getControl(name="form.fst_sit_type").value = ['ssce'] |
|---|
| 65 | self.browser.getControl(name="form.fst_sit_date").value = '01/01/2014' |
|---|
| 66 | self.browser.getControl(name="form.scd_sit_fname").value = 'John' |
|---|
| 67 | self.browser.getControl(name="form.scd_sit_no").value = '456' |
|---|
| 68 | self.browser.getControl(name="form.scd_sit_type").value = ['waec'] |
|---|
| 69 | self.browser.getControl(name="form.alr_fname").value = 'Uli' |
|---|
| 70 | self.browser.getControl(name="form.alr_no").value = '345' |
|---|
| 71 | |
|---|
| 72 | self.browser.getControl("Save").click() |
|---|
| 73 | (success, msg) = self.applicant.createStudent() |
|---|
| 74 | student_id = translate(msg, 'waeup.kofa').split()[1] |
|---|
| 75 | student = self.app['students'][student_id] |
|---|
| 76 | self.assertEqual(student.state, 'admitted') |
|---|
| 77 | |
|---|
| 78 | # Has the student the correct attributes? |
|---|
| 79 | self.assertEqual(student.fst_sit_fname, 'Alfons') |
|---|
| 80 | self.assertEqual(student.fst_sit_no, '123') |
|---|
| 81 | self.assertEqual(student.fst_sit_type, 'ssce') |
|---|
| 82 | self.assertEqual(student.fst_sit_date.isoformat(), '2014-01-01') |
|---|
| 83 | self.assertEqual(student.scd_sit_fname, 'John') |
|---|
| 84 | self.assertEqual(student.scd_sit_no, '456') |
|---|
| 85 | self.assertEqual(student.scd_sit_type, 'waec') |
|---|
| 86 | self.assertEqual(student.alr_fname, 'Uli') |
|---|
| 87 | self.assertEqual(student.alr_no, '345') |
|---|