Ignore:
Timestamp:
27 Jun 2011, 16:59:12 (14 years ago)
Author:
Henrik Bettermann
Message:

Extend the setup of ApplicantsUITests. The test does not pass because it seems that the certificates_catalog does not exist in the test environment.

File:
1 edited

Legend:

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

    r6479 r6482  
    3030from zope.app.testing.functional import HTTPCaller as http
    3131from zope.component import createObject
     32from zope.component.hooks import setSite, clearSite
    3233from zope.security.interfaces import Unauthorized
    3334from zope.testbrowser.testing import Browser
     
    3637from waeup.sirp.applicants.container import ApplicantsContainer
    3738from waeup.sirp.applicants.applicants import Applicant
    38 
     39from waeup.sirp.university.faculty import Faculty
     40from waeup.sirp.university.department import Department
     41from waeup.sirp.university.certificate import Certificate
     42from waeup.sirp.university.certificatecontainer import CertificateContainer
    3943
    4044class ApplicantsUITests(FunctionalTestCase):
     
    6064        app['applicants']['app2009'] = applicantscontainer
    6165
     66        # Populate university
     67        faculty = Faculty()
     68        department = Department()
     69        cert_container = CertificateContainer()
     70        certificate = Certificate(code='CERT1')
     71        certificate.application_category = 'basic'
     72        app['faculties']['fac1'] = faculty
     73        app['faculties']['fac1']['dep1'] = department
     74        app['faculties']['fac1']['dep1'].certificates = cert_container
     75        app['faculties']['fac1']['dep1'].certificates['CERT1'] = certificate
     76
    6277        # Put the prepopulated site into test ZODB and prepare test
    6378        # browser
    6479        self.getRootFolder()['app'] = app
     80        self.app = self.getRootFolder()['app']
     81        setSite(self.app)
    6582        self.browser = Browser()
    6683        self.browser.handleErrors = False
     
    7895
    7996        # Add an applicant
    80         applicant = Applicant()
     97        self.applicant = Applicant()
    8198        self.pin_applicant = unicode(self.pins[1])
    82         applicant.access_code = self.pin_applicant
    83         app['applicants']['app2009'][self.pin_applicant] = applicant
     99        self.applicant.access_code = self.pin_applicant
     100        app['applicants']['app2009'][self.pin_applicant] = self.applicant
    84101
    85102    def tearDown(self):
    86103        super(ApplicantsUITests, self).tearDown()
     104        clearSite()
    87105        shutil.rmtree(self.dc_root)
    88106
     
    98116            'Manage' in self.browser.contents)
    99117        return
     118
     119    def test_manage_cert_access(self):
     120        # Managers can access CERT1
     121        cert_path = 'http://localhost/app/faculties/fac1/dep1/certificates/CERT1'
     122        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
     123        self.browser.open(cert_path)
     124        self.assertEqual(self.browser.headers['Status'], '200 Ok')
    100125
    101126    def test_manage_access(self):
     
    130155        self.browser.getControl(name="form.prefix").value = ['app']
    131156        self.browser.getControl(name="form.year").value = ['2010']
    132         self.browser.getControl(name="form.provider").value = ['waeup.sirp.applicants.ApplicantsContainer']
     157        self.browser.getControl(name="form.provider").value = [
     158            'waeup.sirp.applicants.ApplicantsContainer']
    133159        self.browser.getControl(name="form.ac_prefix").value = ['APP']
    134160        self.browser.getControl(name="form.application_category").value = ['basic']
     
    175201        self.browser.open(self.applicant_manage_path)
    176202        self.assertEqual(self.browser.headers['Status'], '200 Ok')
    177         self.browser.getControl(name="form.firstname").value = 'Jonathan'
     203        self.browser.getControl(name="form.firstname").value = 'John'
     204        self.browser.getControl(name="form.lastname").value = 'Tester'
     205        self.browser.getControl(name="form.course1").value = ['CERT1']
     206        self.browser.getControl(name="form.date_of_birth").value = 'Jonathan'
     207        self.browser.getControl(name="form.lga").value = ['foreigner']
     208        self.browser.getControl(name="form.sex").value = ['male']
    178209        self.browser.getControl("Save").click()
    179210        self.assertTrue('Required input is missing' in self.browser.contents)
Note: See TracChangeset for help on using the changeset viewer.