Changeset 6118


Ignore:
Timestamp:
16 May 2011, 14:58:30 (13 years ago)
Author:
uli
Message:

Add test where a real applicant is stored and retrieved afterwards via
catalog.

File:
1 edited

Legend:

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

    r6117 r6118  
    2626import tempfile
    2727import unittest
     28from hurry.query import Eq
     29from hurry.query.interfaces import IQuery
    2830from zope.app.testing.functional import FunctionalTestCase
    2931from zope.catalog.interfaces import ICatalog
     
    3335from zope.testbrowser.testing import Browser
    3436from waeup.sirp.app import University
     37from waeup.sirp.applicants.container import ApplicantsContainer
     38from waeup.sirp.applicants.applicants import Applicant
    3539from waeup.sirp.testing import FunctionalLayer
    3640
     
    5761        shutil.rmtree(self.dc_root)
    5862
     63    def create_applicant(self):
     64        # Create an applicant in an applicants container
     65        self.container = ApplicantsContainer()
     66        setSite(self.app)
     67        self.app['applicants']['mystuff'] = self.container
     68        self.applicant = Applicant()
     69        self.ac = u'FOO-666-123456789'
     70        self.applicant.access_code = self.ac
     71        self.app['applicants']['mystuff'][self.ac] = self.applicant
     72        return
     73
    5974    def test_get_applicants_catalog(self):
    6075        # There is no global applicants catalog, but one for each site.
     
    6681        cat = getUtility(ICatalog, name='applicants_catalog')
    6782        self.assertTrue(ICatalog.providedBy(cat))
     83
     84    def test_get_applicant(self):
     85        # Make sure that applicants are really catalogued on creation.
     86        self.create_applicant()
     87        q = getUtility(IQuery)
     88        subquery = Eq(('applicants_catalog', 'access_code'), self.ac)
     89        results = list(q.searchResults(subquery))
     90        self.assertEqual(len(results), 1)
     91
     92        result_applicant = results[0]
     93        self.assertTrue(isinstance(result_applicant, Applicant))
     94        self.assertEqual(result_applicant.access_code, self.ac)
Note: See TracChangeset for help on using the changeset viewer.