Changeset 9672 for main/waeup.kofa/trunk/src/waeup/kofa/tests
- Timestamp:
- 17 Nov 2012, 22:43:58 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/tests/test_reports.py
r9670 r9672 211 211 return 212 212 213 def test_description(self):214 # IReportJobs provide a description of the started job215 self.register_generator('report1')216 args, kw = ['a', 'b'], dict(a=1, b=2)217 job = AsyncReportJob(self.root_folder, 'report1', args=args, kw=kw)218 self.assertEqual(219 job.description,220 "Report 1 ('a', 'b', 1, 2)")221 # w/o args nor kwargs222 job = AsyncReportJob(self.root_folder, 'report1')223 self.assertEqual(224 job.description,225 'Report 1 ()')226 # with args only227 job = AsyncReportJob(self.root_folder, 'report1', args=args)228 self.assertEqual(229 job.description, "Report 1 ('a', 'b')")230 # with keywords only231 job = AsyncReportJob(self.root_folder, 'report1', kw=kw)232 self.assertEqual(233 job.description, "Report 1 (1, 2)")234 return235 236 def test_description_invalid_generator(self):237 # We can get a description even with an invalid generator238 job = AsyncReportJob(self.root_folder, 'NOT EXISTENT')239 self.assertEqual(240 job.description, u'Unregistered Report Generator ()')241 # with args set (no kws)242 job = AsyncReportJob(243 self.root_folder, 'NOT EXISTENT', args=['a', 'b'])244 self.assertEqual(245 job.description, u"Unregistered Report Generator ('a', 'b')")246 # with kw set (no args)247 job = AsyncReportJob(248 self.root_folder, 'NOT_EXISTENT', kw=dict(a=1, b=2))249 self.assertEqual(250 job.description, u'Unregistered Report Generator (1, 2)')251 # with args and kws set252 job = AsyncReportJob(253 self.root_folder, 'NOT_EXISTENT', args=['a'], kw=dict(b=2))254 self.assertEqual(255 job.description, u"Unregistered Report Generator ('a', 2)")256 return257 258 def test_report_status(self):259 # We can get a report status apart from the job status260 job = AsyncReportJob(self.root_folder, 'report1')261 self.assertEqual(job.report_status, u'running')262 return263 264 def test_report_status_failed(self):265 # A failed job is reflected in report_status266 job = AsyncReportJob(self.root_folder, None) # no report generator267 setSite(self.root_folder)268 self.assertTrue(job.failed is None)269 manager = getUtility(IJobManager)270 manager.put(job)271 wait_for_result(job)272 self.assertEqual(job.report_status, u'FAILED')273 return274 275 def test_report_status_finished(self):276 # A finished report is reflected in report_status277 job = AsyncReportJob(self.root_folder, 'report1')278 setSite(self.root_folder)279 manager = getUtility(IJobManager)280 manager.put(job)281 wait_for_result(job)282 self.assertEqual(job.report_status, u'finished')283 return284 285 213 class FakeJobWithResult(FakeJob): 286 214 … … 383 311 [('new', u'new', u'Report 1'), 384 312 ('completed', u'completed', u'Report 1')] 385 )386 return387 388 def test_get_report_job_description(self):389 # we can get the descriptions of jobs...390 container = ReportJobContainer()391 container.start_report_job('report1', 'alice')392 container.start_report_job('report1', 'bob')393 result = container.get_report_jobs_description(user_id='bob')394 # we'll get the job id, a description and the status395 self.assertEqual(396 result,397 [('2', 'Report 1 ()', u'running', False, False, True, None, 'bob'),]398 313 ) 399 314 return
Note: See TracChangeset for help on using the changeset viewer.