- Timestamp:
- 26 Sep 2013, 09:37:25 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_browser.py
r10645 r10655 28 28 from datetime import datetime, date, timedelta 29 29 from mechanize import LinkNotFoundError 30 from zc.async.testing import wait_for_result 30 31 from zope.event import notify 31 32 from zope.catalog.interfaces import ICatalog … … 42 43 from waeup.kofa.applicants.applicant import Applicant 43 44 from waeup.kofa.interfaces import ( 44 IExtFileStore, IFileStoreNameChooser, IUserAccount )45 IExtFileStore, IFileStoreNameChooser, IUserAccount, IJobManager) 45 46 from waeup.kofa.university.faculty import Faculty 46 47 from waeup.kofa.university.department import Department 48 from waeup.kofa.tests.test_async import FunctionalAsyncTestCase 47 49 48 50 PH_LEN = 15911 # Length of placeholder file … … 1120 1122 'An email with your user name and password has been sent' 1121 1123 in self.browser.contents) 1124 1125 class 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.