source: main/kofacustom.coewarri/trunk/src/kofacustom/coewarri/applicants/tests/test_browser.py

Last change on this file was 16369, checked in by Henrik Bettermann, 4 years ago

Fix tests.

  • Property svn:keywords set to Id
File size: 3.8 KB
RevLine 
[10765]1## $Id: test_browser.py 16369 2021-01-13 09:03:39Z henrik $
2##
3## Copyright (C) 2013 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"""
19Test the applicant-related UI components.
20"""
[11543]21import os
22import datetime
23from zope.component import createObject, getUtility
24from zope.catalog.interfaces import ICatalog
25from zope.intid.interfaces import IIntIds
[11941]26from hurry.workflow.interfaces import IWorkflowState
[14035]27from kofacustom.coewarri.testing import FunctionalLayer
[11941]28from waeup.kofa.browser.tests.test_pdf import samples_dir
[10765]29from waeup.kofa.applicants.tests.test_browser import ApplicantsFullSetup
[11543]30from waeup.kofa.applicants.tests.test_batching import ApplicantImportExportSetup
[14035]31from kofacustom.coewarri.applicants.export import CustomApplicantExporter
32from kofacustom.coewarri.applicants.batching import CustomApplicantProcessor
[10765]33
34class CustomApplicantUITests(ApplicantsFullSetup):
35    # Tests for uploading/browsing the passport image of appplicants
36
37    layer = FunctionalLayer
[11543]38
[12084]39class ApplicantExporterTest(ApplicantImportExportSetup):
[11543]40
41    layer = FunctionalLayer
42
43    def setUp(self):
[12084]44        super(ApplicantExporterTest, self).setUp()
[11543]45        self.outfile = os.path.join(self.workdir, 'myoutput.csv')
46        self.cat = getUtility(ICatalog, name='applicants_catalog')
47        self.intids = getUtility(IIntIds)
48        return
49
50    def setup_applicant(self, applicant):
51        # set predictable values for `applicant`
52        applicant.reg_number = u'123456'
53        applicant.applicant_id = u'dp2011_654321'
54        applicant.firstname = u'Anna'
55        applicant.lastname = u'Tester'
56        applicant.middlename = u'M.'
57        applicant.nationality = u'NG'
58        applicant.date_of_birth = datetime.date(1981, 2, 4)
59        applicant.sex = 'f'
60        applicant.email = 'anna@sample.com'
61        applicant.phone = u'+234-123-12345'
62        applicant.course1 = self.certificate
63        applicant.course2 = self.certificate
64        applicant.course_admitted = self.certificate
65        applicant.notice = u'Some notice\nin lines.'
66        applicant.screening_score = 98
67        applicant.screening_venue = u'Exam Room'
68        applicant.screening_date = u'Saturday, 16th June 2012 2:00:00 PM'
69        applicant.password = 'any password'
70        return applicant
71
[11941]72class ApplicantsContainerUITests(ApplicantsFullSetup):
73    # Tests for ApplicantsContainer class views and pages
74
75    layer = FunctionalLayer
76
[14092]77    def test_application_slip(self):
[11941]78        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
79        self.slip_path = self.view_path + '/application_slip.pdf'
80        self.browser.open(self.manage_path)
81        self.assertEqual(self.browser.headers['Status'], '200 Ok')
82        self.fill_correct_values()
83        self.browser.getControl("Save").click()
84        IWorkflowState(self.applicant).setState('submitted')
[16369]85        self.browser.open(self.view_path)
[11941]86        self.browser.getLink("Download application slip").click()
87        self.assertEqual(self.browser.headers['Status'], '200 Ok')
88        self.assertEqual(self.browser.headers['Content-Type'],
89                         'application/pdf')
90        path = os.path.join(samples_dir(), 'application_slip.pdf')
91        open(path, 'wb').write(self.browser.contents)
92        print "Sample application_slip.pdf written to %s" % path
Note: See TracBrowser for help on using the repository browser.