Changeset 9820 for main/waeup.kofa/trunk/src/waeup
- Timestamp:
- 21 Dec 2012, 21:00:40 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py
r9814 r9820 27 27 import os 28 28 import grok 29 from zc.async.testing import wait_for_result 29 30 from zope.event import notify 30 from zope.component import createObject, queryUtility 31 from zope.component import createObject, queryUtility, getUtility 31 32 from zope.component.hooks import setSite, clearSite 32 33 from zope.catalog.interfaces import ICatalog … … 42 43 from waeup.kofa.university.faculty import Faculty 43 44 from waeup.kofa.university.department import Department 44 from waeup.kofa.interfaces import IUserAccount 45 from waeup.kofa.interfaces import IUserAccount, IJobManager 45 46 from waeup.kofa.authentication import LocalRoleSetEvent 46 47 from waeup.kofa.hostels.hostel import Hostel, Bed, NOT_OCCUPIED 48 from waeup.kofa.tests.test_async import FunctionalAsyncTestCase 47 49 48 50 PH_LEN = 2059 # Length of placeholder file … … 2726 2728 self.browser.open('http://localhost/app/paymentrequest?P_ID=nonsense') 2727 2729 self.assertEqual(self.browser.contents, '-1') 2730 2731 class StudentDataExportTests(StudentsFullSetup, FunctionalAsyncTestCase): 2732 # Tests for StudentsContainer class views and pages 2733 2734 layer = FunctionalLayer 2735 2736 def wait_for_export_job_completed(self): 2737 # helper function waiting until the current export job is completed 2738 manager = getUtility(IJobManager) 2739 job_id = self.app['datacenter'].running_exports[0][0] 2740 job = manager.get(job_id) 2741 wait_for_result(job) 2742 return job_id 2743 2744 def test_department_export(self): 2745 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 2746 dep1_path = 'http://localhost/app/faculties/fac1/dep1' 2747 self.browser.open(dep1_path) 2748 self.browser.getLink("Export student data").click() 2749 self.browser.getControl("Configure new export").click() 2750 self.browser.getControl(name="exporter").value = ['students'] 2751 self.browser.getControl(name="session").value = ['2004'] 2752 self.browser.getControl(name="level").value = ['100'] 2753 self.browser.getControl(name="mode").value = ['ug_ft'] 2754 self.browser.getControl("Create export now").click() 2755 2756 # When the job is finished and we reload the page... 2757 job_id = self.wait_for_export_job_completed() 2758 self.browser.open(dep1_path + '/exports') 2759 # ... the csv file can be downloaded ... 2760 self.browser.getLink("Download").click() 2761 self.assertEqual(self.browser.headers['content-type'], 2762 'text/csv; charset=UTF-8') 2763 self.assertTrue( 2764 'filename="students.csv' in 2765 self.browser.headers['content-disposition']) 2766 self.assertEqual(len(self.app['datacenter'].running_exports), 1) 2767 job_id = self.app['datacenter'].running_exports[0][0] 2768 # ... and discarded 2769 self.browser.open(dep1_path + '/exports') 2770 self.browser.getControl("Discard").click() 2771 self.assertEqual(len(self.app['datacenter'].running_exports), 0) 2772 # Creation, downloading and discarding is logged 2773 #logfile = os.path.join( 2774 # self.app['datacenter'].storage, 'logs', 'datacenter.log') 2775 #logcontent = open(logfile).read()
Note: See TracChangeset for help on using the changeset viewer.