Ignore:
Timestamp:
23 Jul 2011, 14:26:46 (13 years ago)
Author:
uli
Message:

Reorganize tests a bit and add test case for QueryResultItem? (although
this component does not seem to be used yet).

File:
1 edited

Legend:

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

    r6472 r6548  
    2828from zope.component import queryUtility
    2929from zope.component.hooks import setSite, clearSite
     30from zope.interface.verify import verifyClass, verifyObject
    3031from waeup.sirp.app import University
     32from waeup.sirp.interfaces import IQueryResultItem
    3133from waeup.sirp.testing import FunctionalLayer
    3234from waeup.sirp.accesscodes.accesscodes import (
    3335    AccessCode, AccessCodeBatch, invalidate_accesscode, disable_accesscode)
    3436from waeup.sirp.accesscodes.workflow import INITIALIZED, USED, DISABLED
     37from waeup.sirp.accesscodes.catalog import AccessCodeQueryResultItem
    3538
    36 
    37 class AccessCodeCatalogTests(FunctionalTestCase):
    38     # Tests for helpers like get_access_code, disable_accesscode, ...
    39 
     39class CatalogTestSetup(FunctionalTestCase):
     40    # A setup for testing accesscode catalog related stuff.
     41    #
     42    # sets up a site with some accesscode batches already created.
    4043    layer = FunctionalLayer
    4144
    4245    def setUp(self):
    43         super(AccessCodeCatalogTests, self).setUp()
     46        super(CatalogTestSetup, self).setUp()
    4447
    4548        # Prepopulate ZODB
     
    7073    def tearDown(self):
    7174        shutil.rmtree(self.dc_root)
    72         super(AccessCodeCatalogTests, self).tearDown()
     75        super(CatalogTestSetup, self).tearDown()
    7376        return
     77
     78
     79class AccessCodeCatalogTests(CatalogTestSetup):
     80    # Tests for helpers like get_access_code, disable_accesscode, ...
     81
     82    layer = FunctionalLayer
    7483
    7584    def test_get_catalog(self):
     
    160169        result = cat.searchResults(state=(USED, USED))
    161170        assert len(result) == 1
     171
     172class FakeView(object):
     173    # A view we can use in tests. Provides only the neccessary methods.
     174    def url(self, context):
     175        pass
     176
     177class AccessCodeQueryResultItemTests(CatalogTestSetup):
     178    # Test query result items
     179
     180    layer = FunctionalLayer
     181
     182    def test_ifaces(self):
     183        # Make sure we implement the interfaces correctly
     184        view = FakeView()
     185        self.assertTrue(verifyClass(
     186                IQueryResultItem, AccessCodeQueryResultItem))
     187        item = AccessCodeQueryResultItem(self.ac1, view)
     188        self.assertTrue(verifyObject(
     189                IQueryResultItem, item))
     190        return
     191
Note: See TracChangeset for help on using the changeset viewer.