Ignore:
Timestamp:
17 Nov 2012, 22:43:58 (12 years ago)
Author:
uli
Message:

Try to rip out all UI-related stuff from w.k.reports. Put it into views.

File:
1 edited

Legend:

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

    r9670 r9672  
    211211        return
    212212
    213     def test_description(self):
    214         # IReportJobs provide a description of the started job
    215         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 kwargs
    222         job = AsyncReportJob(self.root_folder, 'report1')
    223         self.assertEqual(
    224             job.description,
    225             'Report 1 ()')
    226         # with args only
    227         job = AsyncReportJob(self.root_folder, 'report1', args=args)
    228         self.assertEqual(
    229             job.description, "Report 1 ('a', 'b')")
    230         # with keywords only
    231         job = AsyncReportJob(self.root_folder, 'report1', kw=kw)
    232         self.assertEqual(
    233             job.description, "Report 1 (1, 2)")
    234         return
    235 
    236     def test_description_invalid_generator(self):
    237         # We can get a description even with an invalid generator
    238         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 set
    252         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         return
    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 
    285213class FakeJobWithResult(FakeJob):
    286214
     
    383311            [('new', u'new', u'Report 1'),
    384312             ('completed', u'completed', u'Report 1')]
    385             )
    386         return
    387 
    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 status
    395         self.assertEqual(
    396             result,
    397             [('2', 'Report 1 ()', u'running', False, False, True, None, 'bob'),]
    398313            )
    399314        return
Note: See TracChangeset for help on using the changeset viewer.