Index: /main/waeup.sirp/trunk/src/waeup/sirp/applicants/tests/test_browser.py
===================================================================
--- /main/waeup.sirp/trunk/src/waeup/sirp/applicants/tests/test_browser.py	(revision 6482)
+++ /main/waeup.sirp/trunk/src/waeup/sirp/applicants/tests/test_browser.py	(revision 6483)
@@ -53,4 +53,16 @@
         app = University()
         self.dc_root = tempfile.mkdtemp()
+        app['datacenter'].setStoragePath(self.dc_root)
+
+        # Prepopulate the ZODB...
+        self.getRootFolder()['app'] = app
+        # we add the site immediately after creation to the
+        # ZODB. Catalogs and other local utilities are not setup
+        # before that step.
+        self.app = self.getRootFolder()['app']
+        # Set site here. Some of the following setup code might need
+        # to access grok.getSite() and should get our new app then
+        setSite(app)
+
         self.root_path = 'http://localhost/app/applicants/'
         self.container_path = 'http://localhost/app/applicants/app2009/'
@@ -62,27 +74,22 @@
         applicantscontainer.year = 2009
         applicantscontainer.application_category = 'basic'
-        app['applicants']['app2009'] = applicantscontainer
+        self.app['applicants']['app2009'] = applicantscontainer
 
         # Populate university
-        faculty = Faculty()
-        department = Department()
-        cert_container = CertificateContainer()
-        certificate = Certificate(code='CERT1')
+        certificate = createObject('waeup.Certificate')
+        certificate.code = 'CERT1'
         certificate.application_category = 'basic'
-        app['faculties']['fac1'] = faculty
-        app['faculties']['fac1']['dep1'] = department
-        app['faculties']['fac1']['dep1'].certificates = cert_container
-        app['faculties']['fac1']['dep1'].certificates['CERT1'] = certificate
+        self.app['faculties']['fac1'] = Faculty()
+        self.app['faculties']['fac1']['dep1'] = Department()
+        self.app['faculties']['fac1']['dep1'].certificates.addCertificate(
+            certificate)
 
         # Put the prepopulated site into test ZODB and prepare test
         # browser
-        self.getRootFolder()['app'] = app
-        self.app = self.getRootFolder()['app']
-        setSite(self.app)
         self.browser = Browser()
         self.browser.handleErrors = False
 
         # Create 5 access codes with prefix'FOO' and cost 9.99 each
-        pin_container = self.getRootFolder()['app']['accesscodes']
+        pin_container = self.app['accesscodes']
         pin_container.createBatch(
             datetime.now(), 'some_userid', 'APP', 9.99, 5)
@@ -92,5 +99,4 @@
         parts = self.existing_pin.split('-')[1:]
         self.existing_series, self.existing_number = parts
-        self.browser.handleErrors = False
 
         # Add an applicant
@@ -99,4 +105,5 @@
         self.applicant.access_code = self.pin_applicant
         app['applicants']['app2009'][self.pin_applicant] = self.applicant
+        return
 
     def tearDown(self):
@@ -206,5 +213,5 @@
         self.browser.getControl(name="form.date_of_birth").value = 'Jonathan'
         self.browser.getControl(name="form.lga").value = ['foreigner']
-        self.browser.getControl(name="form.sex").value = ['male']
+        self.browser.getControl(name="form.sex").value = ['m']
         self.browser.getControl("Save").click()
         self.assertTrue('Required input is missing' in self.browser.contents)
