source: main/kofacustom.skeleton/trunk/src/kofacustom/skeleton/applicants/tests/test_browser.py @ 15185

Last change on this file since 15185 was 14276, checked in by Henrik Bettermann, 8 years ago

Fix test.

Adjust interswitch/browser.py to ease customization.

  • Property svn:keywords set to Id
File size: 3.9 KB
Line 
1## $Id: test_browser.py 14276 2016-11-15 09:53:58Z 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"""
21import os
22import datetime
23from zope.component import createObject, getUtility
24from zope.catalog.interfaces import ICatalog
25from zope.intid.interfaces import IIntIds
26from hurry.workflow.interfaces import IWorkflowState
27from kofacustom.skeleton.testing import FunctionalLayer
28from waeup.kofa.browser.tests.test_pdf import samples_dir
29from waeup.kofa.applicants.tests.test_browser import ApplicantsFullSetup
30from waeup.kofa.applicants.tests.test_batching import ApplicantImportExportSetup
31from kofacustom.skeleton.applicants.export import CustomApplicantExporter
32from kofacustom.skeleton.applicants.batching import CustomApplicantProcessor
33
34class CustomApplicantUITests(ApplicantsFullSetup):
35    # Tests for uploading/browsing the passport image of appplicants
36
37    layer = FunctionalLayer
38
39class ApplicantExporterTest(ApplicantImportExportSetup):
40
41    layer = FunctionalLayer
42
43    def setUp(self):
44        super(ApplicantExporterTest, self).setUp()
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
72class ApplicantsContainerUITests(ApplicantsFullSetup):
73    # Tests for ApplicantsContainer class views and pages
74
75    layer = FunctionalLayer
76
77    def test_application_slip(self):
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')
85        self.browser.open(self.manage_path)
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.