Changeset 6120 for main/waeup.sirp


Ignore:
Timestamp:
16 May 2011, 17:21:12 (13 years ago)
Author:
uli
Message:

Update helper tests to use valid ApplicantsContainer? and Applicant
instances and run all this in a functional environment. We need that
expensive setup because working catalogs require a fully functional
setup.

File:
1 edited

Legend:

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

    r5867 r6120  
    2424"""
    2525import logging
     26import shutil
     27import tempfile
    2628import unittest
    2729from StringIO import StringIO
     30from zope.app.testing.functional import FunctionalTestCase
    2831from zope.component.hooks import setSite, clearSite
    2932from zope.interface.verify import verifyClass, verifyObject
     
    3740    ApplicantsRoot, ApplicantsPlugin,
    3841    )
    39 from waeup.sirp.testing import WAeUPSIRPUnitTestLayer
     42from waeup.sirp.testing import FunctionalLayer
     43
     44
    4045
    4146
     
    149154        return
    150155
    151 applicant = Applicant()
    152 fake_apps = {
    153     'cest10' : ApplicantsContainer(),
    154     'cest11' : ApplicantsContainer(),
    155     }
    156 
    157 fake_apps['cest10']['APP-99999'] = applicant
    158 
    159 class HelperToolsTest(unittest.TestCase):
    160 
    161     layer = WAeUPSIRPUnitTestLayer
    162    
     156
     157class HelperToolsTest(FunctionalTestCase):
     158
     159    layer = FunctionalLayer
     160
    163161    def setUp(self):
    164         self.app = University()
    165         # Insert some applicants...
    166         for container, data in fake_apps.items():
    167             self.app['applicants'][container] = data
    168         self.app.setSiteManager(LocalSiteManager(self.app))
     162        super(HelperToolsTest, self).setUp()
     163
     164        # Setup a sample site for each test
     165        app = University()
     166        self.dc_root = tempfile.mkdtemp()
     167        app['datacenter'].setStoragePath(self.dc_root)
     168
     169        # Prepopulate the ZODB...
     170        self.getRootFolder()['app'] = app
     171        self.app = self.getRootFolder()['app']
    169172        setSite(self.app)
     173
     174        # Insert some applicants containers and applicants...
     175        self.container1 = ApplicantsContainer()
     176        self.app['applicants']['foo'] = self.container1
     177        self.container2 = ApplicantsContainer()
     178        self.app['applicants']['bar'] = self.container2
     179        self.ac = u'APP-99999'
     180        self.applicant = Applicant()
     181        self.applicant.access_code = self.ac
     182        self.app['applicants']['foo'][self.ac] = self.applicant
    170183        return
    171184
    172185    def tearDown(self):
    173         clearSite()
     186        super(HelperToolsTest, self).tearDown()
     187        shutil.rmtree(self.dc_root)
    174188        return
    175189
     
    184198    def test_get_applicant_data(self):
    185199        result = get_applicant_data('APP-99999')
    186         self.assertEqual(result, applicant)
     200        self.assertEqual(result, self.applicant)
    187201        return
    188202
     
    191205        assert result is None
    192206        return
    193    
     207
    194208def suite():
    195209    suite = unittest.TestSuite()
Note: See TracChangeset for help on using the changeset viewer.