Changeset 7043


Ignore:
Timestamp:
8 Nov 2011, 21:57:33 (13 years ago)
Author:
uli
Message:

Add missing tests.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/branches/ulif-extimgstore/src/waeup/sirp/applicants/tests/test_authentication.py

    r6730 r7043  
    2424import unittest
    2525from zope.authentication.interfaces import IAuthentication
    26 from zope.component import provideAdapter, getUtility
     26from zope.component import provideAdapter, getUtility, queryUtility
    2727from zope.component.hooks import setSite
    2828from zope.interface import verify
     
    3535from waeup.sirp.testing import FunctionalLayer, FunctionalTestCase
    3636from waeup.sirp.app import University
     37from waeup.sirp.interfaces import IAuthPluginUtility
    3738from waeup.sirp.applicants import  ApplicantsContainer, Applicant
    3839from waeup.sirp.applicants.authentication import (
    3940    ApplicantsAuthenticatorPlugin, WAeUPApplicantCredentialsPlugin,
    4041    ApplicantCredentials, AuthenticatedApplicantPrincipalFactory,
    41     ApplicantPrincipalInfo, ApplicantPrincipal,)
     42    ApplicantPrincipalInfo, ApplicantPrincipal, ApplicantsAuthUtility)
    4243
    4344
     
    367368        return
    368369
    369 def test_suite():
    370     suite = unittest.TestSuite()
    371     for testcase in [
    372         AuthenticatorPluginTest, CredentialsPluginTest,
    373         ApplicantCredentialsTest, PrincipalFactoryTest,
    374         PAUSetupTest,
    375         ]:
    376         suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
    377                 testcase
    378                 )
    379         )
    380     return suite
     370class FakePAU(object):
     371    credentialsPlugins = ()
     372    authenticatorPlugins = ()
     373
     374class ApplicantsAuthUtilityTests(FunctionalTestCase):
     375
     376    layer = FunctionalLayer
     377
     378    def test_ifaces(self):
     379        # make sure we fullfill the interface promises
     380        obj = ApplicantsAuthUtility()
     381        verify.verifyClass(IAuthPluginUtility, ApplicantsAuthUtility)
     382        verify.verifyObject(IAuthPluginUtility, obj)
     383        return
     384
     385    def test_utility_available(self):
     386        # we can get an applicant auth utility by lookup
     387        util = queryUtility(IAuthPluginUtility,
     388                            name='applicants_auth_setup')
     389        self.assertTrue(util is not None)
     390        return
     391
     392    def test_register(self):
     393        # make sure we can register additional components
     394        pau = FakePAU()
     395        result = ApplicantsAuthUtility().register(pau)
     396        self.assertEqual(
     397            result.credentialsPlugins, ('applicant_credentials',))
     398        self.assertEqual(
     399            result.authenticatorPlugins, ('applicants',))
     400        return
     401
     402    def test_unregister(self):
     403        # make sure we can unregister applicant auth components
     404        pau = FakePAU()
     405        util = ApplicantsAuthUtility()
     406        pau = util.register(pau)
     407        result = util.unregister(pau)
     408        self.assertEqual(
     409            result.credentialsPlugins, ())
     410        self.assertEqual(
     411            result.authenticatorPlugins, ())
     412        return
Note: See TracChangeset for help on using the changeset viewer.