Changeset 9639
- Timestamp:
- 15 Nov 2012, 15:38:25 (12 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/reports.py
r9638 r9639 32 32 from waeup.kofa.utils.helpers import now 33 33 34 #: A status map that reflects the really interesting types of status 35 #: for reports. 36 #: 37 #: For reports we want to know whether a job was finished 38 #: and/or whether it failed. All the other possible states ('new', 39 #: etc.) are not really interesting in that regard. 40 STATUS_MAP = { 41 'unknown': _('unknown'), 42 'running': _('running'), 43 'finished': _('finished'), 44 'failed': _('FAILED'), 45 } 46 34 47 class IReport(Interface): 35 48 """A report. … … 84 97 title = u"""Textual representation of arguments and keywords.""", 85 98 default = u"", 99 ) 100 101 report_status = schema.TextLine( 102 title = u"""Translated status string.""", 103 default = STATUS_MAP['unknown'], 86 104 ) 87 105 … … 299 317 return True 300 318 return False 319 320 @property 321 def report_status(self): 322 """The status of a report as translated string. 323 """ 324 if not self.finished: 325 return STATUS_MAP['running'] 326 if self.failed: 327 return STATUS_MAP['failed'] 328 return STATUS_MAP['finished'] 301 329 302 330 @property … … 327 355 return name + ' ' + str_repr 328 356 329 330 357 @implementer(IReportJobContainer) 331 358 class ReportJobContainer(object): … … 441 468 manager = getUtility(IJobManager) 442 469 job = manager.get(job_id) 443 status = JOB_STATUS_MAP.get(job.status, job.status)[1]470 status = job.report_status 444 471 discardable = job.finished 445 472 downloadable = job.finished and not job.failed -
main/waeup.kofa/trunk/src/waeup/kofa/tests/test_reports.py
r9638 r9639 256 256 return 257 257 258 def test_report_status(self): 259 # We can get a report status apart from the job status 260 job = AsyncReportJob(self.root_folder, 'report1') 261 self.assertEqual(job.report_status, u'running') 262 return 263 264 def test_report_status_failed(self): 265 # A failed job is reflected in report_status 266 job = AsyncReportJob(self.root_folder, None) # no report generator 267 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 return 274 275 def test_report_status_finished(self): 276 # A finished report is reflected in report_status 277 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 return 284 258 285 class FakeJobWithResult(FakeJob): 259 286 … … 368 395 self.assertEqual( 369 396 result, 370 [('2', 'Report 1 ()', u' new', False, False),]397 [('2', 'Report 1 ()', u'running', False, False),] 371 398 ) 372 399 return
Note: See TracChangeset for help on using the changeset viewer.