- Timestamp:
- 30 Jan 2020, 22:47:56 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/students/reports/tests/test_level_report.py
r14605 r15968 1 1 import os 2 2 from zc.async.testing import wait_for_result 3 from zope.event import notify 3 4 from zope.interface.verify import verifyClass, verifyObject 5 from zope.securitypolicy.interfaces import IPrincipalRoleManager 4 6 from zope.component import getUtility, createObject 5 7 from waeup.kofa.interfaces import IJobManager … … 9 11 from waeup.kofa.students.tests.test_browser import StudentsFullSetup 10 12 from waeup.kofa.testing import FunctionalLayer 13 from waeup.kofa.authentication import LocalRoleSetEvent 11 14 from waeup.kofa.tests.test_async import FunctionalAsyncTestCase 12 15 from waeup.kofa.browser.tests.test_pdf import samples_dir 16 from waeup.kofa.tests.test_authentication import SECRET 13 17 14 18 class LevelReportTests(CatalogTestSetup): … … 112 116 113 117 def trigger_report_creation(self): 114 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 118 #self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 119 # Create reports officer 120 self.app['users'].addUser('mrreport', SECRET) 121 self.app['users']['mrreport'].email = 'mrreport@foo.ng' 122 self.app['users']['mrreport'].title = 'Carlo Pitter' 123 # Assign global reports officer role 124 prmglobal = IPrincipalRoleManager(self.app) 125 prmglobal.assignRoleToPrincipal('waeup.ReportsOfficer', 'mrreport') 126 # Assign local ReportsOfficer role which restricts the access to 127 # certain faculties. 128 self.department = self.app['faculties']['fac1']['dep1'] 129 prmlocal = IPrincipalRoleManager(self.department) 130 prmlocal.assignRoleToPrincipal( 131 'waeup.local.ReportsOfficer', 'mrreport') 132 notify(LocalRoleSetEvent( 133 self.department, 'waeup.local.ReportsOfficer', 'mrreport', 134 granted=True)) 135 # Login as reports officer 136 self.browser.open(self.login_path) 137 self.browser.getControl(name="form.login").value = 'mrreport' 138 self.browser.getControl(name="form.password").value = SECRET 139 self.browser.getControl("Login").click() 115 140 self.browser.open('http://localhost/app/reports') 116 141 self.assertEqual(self.browser.headers['Status'], '200 Ok') … … 148 173 logcontent = open(logfile).read() 149 174 self.assertTrue( 150 'INFO - zope.mgr- students.reports.level_report.LevelReportGeneratorPage - '175 'INFO - mrreport - students.reports.level_report.LevelReportGeneratorPage - ' 151 176 'report %s created: Level Report (faculty=fac1, department=dep1, ' 152 177 'certificate=CERT1, session=2010, level=100)' … … 154 179 ) 155 180 self.assertTrue( 156 'INFO - zope.mgr- students.reports.level_report.LevelReportPDFView - '181 'INFO - mrreport - students.reports.level_report.LevelReportPDFView - ' 157 182 'report %s downloaded: LevelReport_rno%s' 158 183 % (job_id, job_id) in logcontent 159 184 ) 160 185 self.assertTrue( 161 'INFO - zope.mgr- browser.reports.ReportsContainerPage - '186 'INFO - mrreport - browser.reports.ReportsContainerPage - ' 162 187 'report %s discarded' % job_id in logcontent 163 188 )
Note: See TracChangeset for help on using the changeset viewer.