Ignore:
Timestamp:
26 Sep 2013, 09:37:25 (11 years ago)
Author:
Henrik Bettermann
Message:

Implement an VirtualApplicantsExportJobContainer? which allows to export applicants locally. On each container page there is now an'Export applicants' button which directs to the exports overview page. Unlike student exporters, the applicants exporter can't be configured. It just exports all applicants in the container.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_browser.py

    r10645 r10655  
    2828from datetime import datetime, date, timedelta
    2929from mechanize import LinkNotFoundError
     30from zc.async.testing import wait_for_result
    3031from zope.event import notify
    3132from zope.catalog.interfaces import ICatalog
     
    4243from waeup.kofa.applicants.applicant import Applicant
    4344from waeup.kofa.interfaces import (
    44     IExtFileStore, IFileStoreNameChooser, IUserAccount)
     45    IExtFileStore, IFileStoreNameChooser, IUserAccount, IJobManager)
    4546from waeup.kofa.university.faculty import Faculty
    4647from waeup.kofa.university.department import Department
     48from waeup.kofa.tests.test_async import FunctionalAsyncTestCase
    4749
    4850PH_LEN = 15911  # Length of placeholder file
     
    11201122            'An email with your user name and password has been sent'
    11211123            in self.browser.contents)
     1124
     1125class ApplicantsExportTests(ApplicantsFullSetup, FunctionalAsyncTestCase):
     1126    # Tests for StudentsContainer class views and pages
     1127
     1128    layer = FunctionalLayer
     1129
     1130    def wait_for_export_job_completed(self):
     1131        # helper function waiting until the current export job is completed
     1132        manager = getUtility(IJobManager)
     1133        job_id = self.app['datacenter'].running_exports[0][0]
     1134        job = manager.get(job_id)
     1135        wait_for_result(job)
     1136        return job_id
     1137
     1138    def test_applicants_in_container_export(self):
     1139        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
     1140        container_path = 'http://localhost/app/applicants/app2011'
     1141        self.browser.open(container_path)
     1142        self.browser.getLink("Export applicants").click()
     1143        self.browser.getControl("Start new export").click()
     1144
     1145        # When the job is finished and we reload the page...
     1146        job_id = self.wait_for_export_job_completed()
     1147        self.browser.open(container_path + '/exports')
     1148        # ... the csv file can be downloaded ...
     1149        self.browser.getLink("Download").click()
     1150        self.assertEqual(self.browser.headers['content-type'],
     1151            'text/csv; charset=UTF-8')
     1152        self.assertTrue(
     1153            'filename="WAeUP.Kofa_applicants_%s.csv' % job_id in
     1154            self.browser.headers['content-disposition'])
     1155        self.assertEqual(len(self.app['datacenter'].running_exports), 1)
     1156        job_id = self.app['datacenter'].running_exports[0][0]
     1157        # ... and discarded
     1158        self.browser.open(container_path + '/exports')
     1159        self.browser.getControl("Discard").click()
     1160        self.assertEqual(len(self.app['datacenter'].running_exports), 0)
     1161        # Creation, downloading and discarding is logged
     1162        logfile = os.path.join(
     1163            self.app['datacenter'].storage, 'logs', 'datacenter.log')
     1164        logcontent = open(logfile).read()
     1165        self.assertTrue(
     1166            'zope.mgr - applicants.browser.ExportJobContainerJobStart - '
     1167            'exported: applicants (app2011), job_id=%s'
     1168            % job_id in logcontent
     1169            )
     1170        self.assertTrue(
     1171            'zope.mgr - applicants.browser.ExportJobContainerDownload '
     1172            '- downloaded: WAeUP.Kofa_applicants_%s.csv, job_id=%s'
     1173            % (job_id, job_id) in logcontent
     1174            )
     1175        self.assertTrue(
     1176            'zope.mgr - applicants.browser.ExportJobContainerOverview '
     1177            '- discarded: job_id=%s' % job_id in logcontent
     1178            )
Note: See TracChangeset for help on using the changeset viewer.