Ignore:
Timestamp:
25 Jun 2016, 08:26:16 (8 years ago)
Author:
Henrik Bettermann
Message:

Improve RefereeReportAddFormPage? and add tests.

File:
1 edited

Legend:

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

    r13976 r13991  
    4747from waeup.kofa.university.faculty import Faculty
    4848from waeup.kofa.university.department import Department
     49from waeup.kofa.mandates.mandate import RefereeReportMandate
    4950from waeup.kofa.tests.test_async import FunctionalAsyncTestCase
    5051
     
    15251526    layer = FunctionalLayer
    15261527
     1528    def test_refereereport_mandate(self):
     1529        mandate = RefereeReportMandate()
     1530        mandate.params['name'] = u'John Referee'
     1531        mandate.params['email'] = 'aa@aa.aa'
     1532        mandate.params[
     1533            'redirect_path'] = '/applicants/%s/%s/addrefereereport' % (
     1534                container_name_1, self.applicant.application_number)
     1535        self.app['mandates'].addMandate(mandate)
     1536        # Let's open the add form page via the mandate view
     1537        self.browser.open('http://localhost/app/mandate?mandate_id=%s'
     1538            % mandate.mandate_id)
     1539        # Form page opens and is prefilled
     1540        self.assertEqual(
     1541            self.browser.url,
     1542            'http://localhost/app/applicants/%s/%s/addrefereereport?mandate_id=%s'
     1543            % (container_name_1, self.applicant.application_number,
     1544            mandate.mandate_id))
     1545        self.assertTrue('value="John Referee"' in self.browser.contents)
     1546        # Let's open the page directly with an invalid mandate
     1547        self.browser.open(
     1548            'http://localhost/app/applicants/%s/%s/addrefereereport?mandate_id=wrongmadate'
     1549            % (container_name_1, self.applicant.application_number))
     1550        self.assertTrue('<div class="alert alert-warning">No mandate.</div>'
     1551            in self.browser.contents)
     1552        self.assertEqual(self.browser.url, 'http://localhost/app')
     1553        # Page is also blocked in maintenance mode
     1554        grok.getSite()['configuration'].maintmode_enabled_by = u'anybody'
     1555        self.browser.open(
     1556            'http://localhost/app/applicants/%s/%s/addrefereereport?mandate_id=%s'
     1557            % (container_name_1, self.applicant.application_number,
     1558            mandate.mandate_id))
     1559        self.assertTrue('<div class="alert alert-warning">The portal is '
     1560                        'in maintenance mode'
     1561            in self.browser.contents)
     1562        self.assertEqual(self.browser.url, 'http://localhost/app')
     1563
    15271564    def test_add_and_view_reports(self):
    1528         # Managers can view reports
    1529         self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
    1530         self.browser.open(self.manage_path)
    1531         # So far no report has been added
    1532         self.assertFalse('Referee' in self.browser.contents)
    1533         # XXX: Form will be public
    1534         self.browser.open(self.view_path + '/addrefereereport')
    1535         self.browser.getControl(name="form.name").value = 'John Trust'
    1536         self.browser.getControl(name="form.email").value = 'xx@yy.zz'
     1565        mandate = RefereeReportMandate()
     1566        mandate.params['name'] = u'John Referee'
     1567        mandate.params['email'] = 'aa@aa.aa'
     1568        mandate.params[
     1569            'redirect_path'] = '/applicants/%s/%s/addrefereereport' % (
     1570                container_name_1, self.applicant.application_number)
     1571        self.app['mandates'].addMandate(mandate)
     1572        # Let's open the add form page via the mandate view
     1573        self.browser.open('http://localhost/app/mandate?mandate_id=%s'
     1574            % mandate.mandate_id)
    15371575        self.browser.getControl("Submit").click()
    1538         self.assertTrue('Referee report created' in self.browser.contents)
    1539         # Report has been created and we are viewing the report's index page
     1576        self.assertTrue('Referee report has been saved' in self.browser.contents)
     1577        self.assertEqual(self.browser.url, 'http://localhost/app')
     1578        # Report has been created
    15401579        self.assertEqual(len(self.applicant.refereereports), 1)
    15411580        report = self.applicant.refereereports[0]
     1581        # Managers can view the report
     1582        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
     1583        self.browser.open(self.manage_path)
     1584        self.browser.getLink("%s" % report.r_id).click()
    15421585        self.assertEqual(
    1543             self.browser.url, self.view_path  + '/%s/index' % report.r_id)
     1586            self.browser.url, self.view_path  + '/%s' % report.r_id)
     1587        self.assertTrue('John Referee' in self.browser.contents)
    15441588        # Report creation is logged
    15451589        logfile = os.path.join(
     
    15471591        logcontent = open(logfile).read()
    15481592        self.assertTrue(
    1549             'zope.mgr - applicants.browser.RefereeReportAddFormPage - '
     1593            'zope.anybody - applicants.browser.RefereeReportAddFormPage - '
    15501594            '%s - added: %s\n' % (self.applicant.applicant_id, report.r_id)
    15511595            in logcontent
Note: See TracChangeset for help on using the changeset viewer.