Ignore:
Timestamp:
29 Jun 2011, 08:42:32 (13 years ago)
Author:
uli
Message:

Make browser tests setup work again, finally. I cannot tell, what the
main reason for the problems was. One point was definitely, that the
site object (self.app) was put too late into ZODB. A site must have
been added to the ZODB to have catalogs available, because catalogs
are local utilities and local utilities are set up (event-triggered)
when an associated site is added to the ZODB.

File:
1 edited

Legend:

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

    r6482 r6483  
    5353        app = University()
    5454        self.dc_root = tempfile.mkdtemp()
     55        app['datacenter'].setStoragePath(self.dc_root)
     56
     57        # Prepopulate the ZODB...
     58        self.getRootFolder()['app'] = app
     59        # we add the site immediately after creation to the
     60        # ZODB. Catalogs and other local utilities are not setup
     61        # before that step.
     62        self.app = self.getRootFolder()['app']
     63        # Set site here. Some of the following setup code might need
     64        # to access grok.getSite() and should get our new app then
     65        setSite(app)
     66
    5567        self.root_path = 'http://localhost/app/applicants/'
    5668        self.container_path = 'http://localhost/app/applicants/app2009/'
     
    6274        applicantscontainer.year = 2009
    6375        applicantscontainer.application_category = 'basic'
    64         app['applicants']['app2009'] = applicantscontainer
     76        self.app['applicants']['app2009'] = applicantscontainer
    6577
    6678        # Populate university
    67         faculty = Faculty()
    68         department = Department()
    69         cert_container = CertificateContainer()
    70         certificate = Certificate(code='CERT1')
     79        certificate = createObject('waeup.Certificate')
     80        certificate.code = 'CERT1'
    7181        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
     82        self.app['faculties']['fac1'] = Faculty()
     83        self.app['faculties']['fac1']['dep1'] = Department()
     84        self.app['faculties']['fac1']['dep1'].certificates.addCertificate(
     85            certificate)
    7686
    7787        # Put the prepopulated site into test ZODB and prepare test
    7888        # browser
    79         self.getRootFolder()['app'] = app
    80         self.app = self.getRootFolder()['app']
    81         setSite(self.app)
    8289        self.browser = Browser()
    8390        self.browser.handleErrors = False
    8491
    8592        # Create 5 access codes with prefix'FOO' and cost 9.99 each
    86         pin_container = self.getRootFolder()['app']['accesscodes']
     93        pin_container = self.app['accesscodes']
    8794        pin_container.createBatch(
    8895            datetime.now(), 'some_userid', 'APP', 9.99, 5)
     
    9299        parts = self.existing_pin.split('-')[1:]
    93100        self.existing_series, self.existing_number = parts
    94         self.browser.handleErrors = False
    95101
    96102        # Add an applicant
     
    99105        self.applicant.access_code = self.pin_applicant
    100106        app['applicants']['app2009'][self.pin_applicant] = self.applicant
     107        return
    101108
    102109    def tearDown(self):
     
    206213        self.browser.getControl(name="form.date_of_birth").value = 'Jonathan'
    207214        self.browser.getControl(name="form.lga").value = ['foreigner']
    208         self.browser.getControl(name="form.sex").value = ['male']
     215        self.browser.getControl(name="form.sex").value = ['m']
    209216        self.browser.getControl("Save").click()
    210217        self.assertTrue('Required input is missing' in self.browser.contents)
Note: See TracChangeset for help on using the changeset viewer.