Ignore:
Timestamp:
20 Sep 2016, 11:35:42 (8 years ago)
Author:
Henrik Bettermann
Message:

Add export purge button.

File:
1 edited

Legend:

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

    r14166 r14170  
    2424import os
    2525import grok
     26from datetime import datetime, timedelta
    2627from zc.async.testing import wait_for_result
    2728from zope.component import createObject, getUtility
     
    3233from waeup.kofa.testing import FunctionalLayer, FunctionalTestCase
    3334from waeup.kofa.app import University
    34 from waeup.kofa.interfaces import IJobManager, IUserAccount
     35from waeup.kofa.interfaces import IJobManager, IUserAccount, IKofaUtils
    3536from waeup.kofa.tests.test_async import FunctionalAsyncTestCase
    3637from waeup.kofa.university.faculty import Faculty
     
    435436        # we can discard a generated export result
    436437        self.trigger_export()
    437         self.wait_for_export_job_completed()
     438        job_id = self.wait_for_export_job_completed()
    438439        self.browser.open(self.datacenter_path + '/@@export')
    439440        self.browser.getControl("Discard").click()
     
    443444        logcontent = open(logfile).read()
    444445        self.assertTrue(
    445             'zope.mgr - browser.pages.ExportCSVPage - discarded: job_id='
    446             in logcontent)
     446            'zope.mgr - browser.pages.ExportCSVPage - discarded: job_id=%s'
     447            % job_id in logcontent)
     448        return
     449
     450    def test_export_purge(self):
     451        self.trigger_export()
     452        job_id = self.wait_for_export_job_completed()
     453        self.browser.open(self.datacenter_path + '/export')
     454        self.browser.getControl("Purge").click()
     455        # Flash message always says successful ...
     456        self.assertTrue(
     457            'Exports successfully purged.' in self.browser.contents)
     458        # ... but the export is still there
     459        self.assertEqual(len(self.app['datacenter'].running_exports), 1)
     460
     461        job_id, gen_name, user = self.app['datacenter'].get_running_export_jobs()[0]
     462        job = getUtility(IJobManager).get(job_id)
     463        tz = getUtility(IKofaUtils).tzinfo
     464        delta = timedelta(days=5)
     465        setattr(job, '_begin_after', datetime.now(tz) - delta)
     466        self.browser.getControl("Purge").click()
     467        self.assertEqual(len(self.app['datacenter'].running_exports), 0)
     468        logfile = os.path.join(
     469            self.app['datacenter'].storage, 'logs', 'datacenter.log')
     470        logcontent = open(logfile).read()
     471        self.assertTrue('zope.mgr - browser.pages.ExportCSVPage - '
     472                        'purged: job_id=%s' % job_id in logcontent)
    447473        return
    448474
Note: See TracChangeset for help on using the changeset viewer.