Ignore:
Timestamp:
4 Oct 2012, 12:07:53 (12 years ago)
Author:
uli
Message:

Minor cleanups and (hopefully) last removal of a source of tempdirs in
tests. This one was really hard to find and my own fault.

File:
1 edited

Legend:

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

    r9261 r9290  
    165165        return False
    166166
     167    def trigger_export(self):
     168        # helper to start an export. Make sure to remove the result file
     169        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
     170        self.browser.open(self.datacenter_path)
     171        self.browser.getLink("Export data").click()
     172        self.browser.getControl(name="exporter").value = ['faculties']
     173        self.browser.getControl("Create CSV file").click()
     174        return
     175
     176    def cleanup_run_job(self):
     177        # helper to remove any result file of an export
     178        job_id = self.wait_for_export_job_completed()
     179        manager = getUtility(IJobManager)
     180        job = manager.get(job_id)
     181        if os.path.exists(job.result):
     182            shutil.rmtree(os.path.dirname(job.result))
     183
    167184    def test_export_start(self):
    168185        # we can trigger export file creation
     
    175192        self.browser.getControl("Create CSV file").click()
    176193        self.assertEqual(self.browser.headers['Status'], '200 Ok')
     194        self.cleanup_run_job() # make sure to remove temp dirs
    177195        return
    178196
    179197    def test_export_download(self):
    180198        # we can download a generated export result
    181         self.test_export_start()
     199        self.trigger_export()
    182200        # while the export file is created, we get a reload button
    183201        # (or a loading bar if javascript is enabled)...
     
    264282            '<option value="accesscodebatches">' in self.browser.contents)
    265283        # ... but not the accesscodes exporter.
    266         self.assertFalse('<option value="accesscodes">' in self.browser.contents)
     284        self.assertFalse('<option value="accesscodes">'
     285                         in self.browser.contents)
    267286
    268287    def test_export_discard(self):
    269288        # we can discard a generated export result
    270         self.test_export_start()
     289        self.trigger_export()
    271290        self.wait_for_export_job_completed()
    272291        self.browser.open(self.datacenter_path + '/@@export')
     
    294313
    295314    def test_set_former_course(self):
    296         # A certificate course will be automatically removed when
    297         # the former_course attribute of the corresponding course is set.
     315        # A certificate course will be automatically removed when the
     316        # former_course attribute of the corresponding course is set.
    298317        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
    299318        self.assertTrue(self.app['faculties']['fac1']['dep1'].certificates[
    300319            'CERT1'].has_key('COURSE1_100'))
    301         self.browser.open('http://localhost/app/faculties/fac1/dep1/courses/COURSE1/manage')
     320        self.browser.open(
     321            'http://localhost/app/faculties/fac1/dep1/courses/COURSE1/manage')
    302322        self.browser.getControl(name="form.former_course").value = ['selected']
    303323        self.browser.getControl("Save").click()
Note: See TracChangeset for help on using the changeset viewer.