Ignore:
Timestamp:
20 Apr 2020, 06:30:54 (5 years ago)
Author:
Henrik Bettermann
Message:

Improve referee reports.

File:
1 edited

Legend:

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

    r16058 r16059  
    16611661        mandate.params['name'] = u'John Referee'
    16621662        mandate.params['email'] = 'aa@aa.aa'
     1663        mandate.params['applicant_id'] = self.applicant.applicant_id
    16631664        mandate.params[
    16641665            'redirect_path'] = '/applicants/%s/%s/addrefereereport' % (
     
    16921693            in self.browser.contents)
    16931694        self.assertEqual(self.browser.url, 'http://localhost/app')
     1695        return
    16941696
    16951697    def test_add_and_view_reports(self):
     
    16971699        mandate.params['name'] = u'John Referee'
    16981700        mandate.params['email'] = 'aa@aa.aa'
    1699         mandate.params[
    1700             'redirect_path'] = '/applicants/%s/%s/addrefereereport' % (
     1701        mandate.params['applicant_id'] = self.applicant.applicant_id
     1702        mandate.params['redirect_path'] = '/applicants/%s/%s/addrefereereport' % (
    17011703                container_name_1, self.applicant.application_number)
     1704        mandate.params['redirect_path2'] = ''
    17021705        self.app['mandates'].addMandate(mandate)
    17031706        self.assertEqual(len(self.app['mandates'].keys()), 1)
     
    17121715        self.browser.getControl(name="form.email").value = 'bb@bb.bb'
    17131716        self.browser.getControl("Submit").click()
    1714         self.assertTrue('Referee report has been saved' in self.browser.contents)
    1715         self.assertEqual(self.browser.url, 'http://localhost/app')
     1717        # Referee wil be redirected to a pdf file
     1718        self.assertEqual(self.browser.headers['Status'], '200 Ok')
     1719        self.assertEqual(self.browser.headers['Content-Type'],
     1720                         'application/pdf')
     1721        path = os.path.join(samples_dir(), 'referee_report.pdf')
     1722        open(path, 'wb').write(self.browser.contents)
     1723        print "Sample PDF referee_report.pdf written to %s" % path
    17161724        # Report has been created
    17171725        self.assertEqual(len(self.applicant.refereereports), 1)
    17181726        report = self.applicant.refereereports[0]
     1727        # Referee can use mandate again to download the pdf report
     1728        self.browser.open('http://localhost/app/mandate?mandate_id=%s'
     1729            % mandate.mandate_id)
     1730        self.assertEqual(self.browser.headers['Status'], '200 Ok')
     1731        self.assertEqual(self.browser.headers['Content-Type'],
     1732                         'application/pdf')
    17191733        # Managers can view the report
    17201734        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
     
    17251739        self.assertTrue('John Referee' in self.browser.contents)
    17261740        # Managers can download a pdf slip
    1727         self.browser.getLink("Download report").click()
     1741        self.browser.getLink("Download referee report").click()
    17281742        self.assertEqual(self.browser.headers['Status'], '200 Ok')
    17291743        self.assertEqual(self.browser.headers['Content-Type'],
     
    17321746        open(path, 'wb').write(self.browser.contents)
    17331747        print "Sample PDF referee_report_slip.pdf written to %s" % path
    1734         # Report creation is logged
     1748        # Mandate is not deleted ...
     1749        self.assertEqual(len(self.app['mandates'].keys()), 1)
     1750        # ... but redirect_path2 attribute has been set
     1751        redirect_path2 = '/applicants/%s/%s/%s/referee_report.pdf' % (
     1752                container_name_1,
     1753                self.applicant.application_number,
     1754                report.r_id)
     1755        self.assertEqual(
     1756            self.app['mandates'].values()[0].params['redirect_path2'],
     1757            redirect_path2)
     1758        # Managers can delete referee reports
     1759        self.browser.open(self.manage_path)
     1760        self.browser.getLink("%s" % report.r_id).click()
     1761        self.assertEqual(len(self.applicant.refereereports), 1)
     1762        self.browser.getLink("Delete").click()
     1763        self.assertEqual(len(self.applicant.refereereports), 0)
     1764        self.assertTrue('Referee report removed.' in self.browser.contents)
     1765        self.assertEqual(self.browser.url, self.view_path)
     1766        # Report creation and deletion is logged
    17351767        logfile = os.path.join(
    17361768            self.app['datacenter'].storage, 'logs', 'applicants.log')
     
    17391771            'zope.anybody - applicants.browser.RefereeReportAddFormPage - '
    17401772            '%s - added: %s\n' % (self.applicant.applicant_id, report.r_id)
    1741             in logcontent
    1742             )
    1743         # Mandate is deleted
    1744         self.assertEqual(len(self.app['mandates'].keys()), 0)
     1773            in logcontent)
     1774        self.assertTrue(
     1775            'zope.mgr - applicants.browser.RemoveRefereeReportPage - '
     1776            '%s - removed: %s\n' % (self.applicant.applicant_id, report.r_id)
     1777            in logcontent)
     1778        return
    17451779
    17461780    def test_final_submit_with_referees(self):
Note: See TracChangeset for help on using the changeset viewer.