Ignore:
Timestamp:
22 Sep 2016, 19:43:09 (8 years ago)
Author:
Henrik Bettermann
Message:

Add reports and exports purge buttons.

Add more tests.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/reports/tests/test_contract_statistics.py

    r12663 r14173  
    11# Tests for contract related reports
    22import os
     3from datetime import datetime, timedelta
    34from zc.async.testing import wait_for_result
    45from zope.interface.verify import verifyClass, verifyObject
    56from zope.component import getUtility
    6 from waeup.ikoba.interfaces import IJobManager
     7from waeup.ikoba.interfaces import IJobManager, IIkobaUtils
    78from waeup.ikoba.customers.reports.contract_statistics import (
    89    get_contract_stats, ContractStatisticsReport, IContractStatisticsReport)
     
    118119            )
    119120        return
     121
     122    def test_report_purge(self):
     123        self.trigger_report_creation()
     124        job_id = self.wait_for_report_job_completed()
     125        self.browser.open('http://localhost/app/reports')
     126        self.browser.getControl("Purge").click()
     127        self.assertTrue('0 report(s) purged' in self.browser.contents)
     128        job_id, gen_name, user = self.app['reports'].get_running_report_jobs(user_id=None)[0]
     129        job = getUtility(IJobManager).get(job_id)
     130        tz = getUtility(IIkobaUtils).tzinfo
     131        delta = timedelta(weeks=5)
     132        setattr(job, '_begin_after', datetime.now(tz) - delta)
     133        self.browser.getControl("Purge").click()
     134        self.assertTrue('1 report(s) purged' in self.browser.contents)
     135        logfile = os.path.join(
     136            self.app['datacenter'].storage, 'logs', 'main.log')
     137        logcontent = open(logfile).read()
     138        self.assertTrue(
     139            'INFO - zope.mgr - browser.reports.ReportsContainerPage - '
     140            'report %s purged' % job_id in logcontent
     141            )
     142        return
Note: See TracChangeset for help on using the changeset viewer.