Ignore:
Timestamp:
8 Mar 2011, 02:32:23 (14 years ago)
Author:
uli
Message:

Remove JAMB-related tests and unused imports.

File:
1 edited

Legend:

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

    r5762 r5817  
    2323import unittest
    2424from zope.component import provideAdapter
    25 from zope.component.hooks import setSite
     25from zope.component.hooks import setSite, clearSite
    2626from zope.interface import verify
    2727from zope.pluggableauth.interfaces import  IAuthenticatedPrincipalFactory
    2828from zope.publisher.browser import TestRequest
    2929from zope.publisher.interfaces import IRequest
    30 from zope.session.session import RAMSessionDataContainer
    3130from zope.session.interfaces import ISession
    3231from zope.site import LocalSiteManager
    33 from zope.site.folder import Folder
    34 from zope.site.testing import siteSetUp, siteTearDown
    3532from zope.testing import cleanup
    3633from waeup.sirp.applicants.authentication import (
     
    3835    ApplicantCredentials, AuthenticatedApplicantPrincipalFactory,
    3936    ApplicantPrincipalInfo, ApplicantPrincipal)
    40 from waeup.sirp.applicants.interfaces import(
    41     IJAMBApplicantSessionCredentials,)
    4237
    4338class FakeBatch(dict):
     
    6055    def __init__(self):
    6156        super(FakeSite, self).__init__()
    62         self['applications'] = {
    63             'APP-12345': FakeApplication('APP-12345'),
    64             'APP-54321': FakeApplication('APP-54321'),
    65             'APP-22222': FakeApplication('APP-OTHER'),
    66             'APP-44444': FakeApplication(),
    67             'APP-55555': FakeApplication('APP-OTHER'),
    68             'JAMB1': FakeApplication(),
    69             'JAMB2': FakeApplication('APP-12345'),
    70             'JAMB3': FakeApplication('APP-54321'),
    71             'JAMB4': FakeApplication('APP-44444'),
     57        self['applicants'] = {
     58            'APP': {
     59                'APP-12345': FakeApplication('APP-12345'),
     60                'APP-54321': FakeApplication('APP-54321'),
     61                'APP-22222': FakeApplication('APP-OTHER'),
     62                'APP-44444': FakeApplication(),
     63                'APP-55555': FakeApplication('APP-OTHER'),
     64                },
     65            'JAMB': {
     66                'JAMB1': FakeApplication(),
     67                'JAMB2': FakeApplication('APP-12345'),
     68                'JAMB3': FakeApplication('APP-54321'),
     69                'JAMB4': FakeApplication('APP-44444'),
     70                },
    7271            }
    7372        self['accesscodes'] = {
     
    8685
    8786    def setUp(self):
    88         self.root = Folder()
    89         siteSetUp(self.root)
    90         self.app = FakeSite() #grok.Application()
    91         self.root['app'] = self.app
     87        self.app = FakeSite()
    9288        self.app.setSiteManager(LocalSiteManager(self.app))
    9389        self.plugin = ApplicantsAuthenticatorPlugin()
     
    9692
    9793    def tearDown(self):
    98         siteTearDown()
     94        clearSite()
    9995        return
    10096
     
    108104
    109105        result = self.plugin.authenticateCredentials(
    110             dict(jambregno=None, foo='blah'))
    111         assert result is None
    112 
    113         result = self.plugin.authenticateCredentials(
    114             dict(accesscode=None, jambregno=None))
    115         assert result is None
    116 
    117         result = self.plugin.authenticateCredentials(
    118             dict(accesscode='Nonsense', jambregno='Nonsense'))
    119         assert result is None
    120 
    121         # The nine possible cases, where formal correct authentication
     106            dict(accesscode='Nonsense',))
     107        assert result is None
     108
     109        # Possible cases, where formal correct authentication
    122110        # data is not valid:
    123111        result = self.plugin.authenticateCredentials(
     
    136124            dict(accesscode='APP-55555'))
    137125        assert result is None
    138        
    139         result = self.plugin.authenticateCredentials(
    140             dict(accesscode='APP-12345', jambregno='JAMB-NOT-EXISTENT'))
    141         assert result is None
    142        
    143         result = self.plugin.authenticateCredentials(
    144             dict(accesscode='APP-12345', jambregno='JAMB3'))
    145         assert result is None
    146        
    147         result = self.plugin.authenticateCredentials(
    148             dict(accesscode='APP-54321', jambregno='JAMB-NOT-EXISTENT'))
    149         assert result is None
    150        
    151         result = self.plugin.authenticateCredentials(
    152             dict(accesscode='APP-54321', jambregno='JAMB1'))
    153         assert result is None
    154 
    155         result = self.plugin.authenticateCredentials(
    156             dict(accesscode='APP-54321', jambregno='JAMB2'))
    157         assert result is None
    158        
    159126        return
    160127
     
    174141        result = self.plugin.authenticateCredentials(
    175142            dict(accesscode='APP-54321'))
    176         assert result is not None
    177 
    178         result = self.plugin.authenticateCredentials(
    179             dict(accesscode='APP-12345', jambregno='JAMB1'))
    180 
    181         result = self.plugin.authenticateCredentials(
    182             dict(accesscode='APP-12345', jambregno='JAMB2'))
    183         assert result is not None
    184 
    185         result = self.plugin.authenticateCredentials(
    186             dict(accesscode='APP-54321', jambregno='JAMB3'))
    187143        assert result is not None
    188144
     
    245201                'form.ac_series': '1',
    246202                'form.ac_number': '1234567890',
    247                 'form.jamb_reg_no': 'JAMB_NUMBER',
     203                #'form.jamb_reg_no': 'JAMB_NUMBER',
    248204                })
    249205        result = self.plugin.extractCredentials(request)
    250         self.assertEqual(result, {'jambregno': 'JAMB_NUMBER',
    251                                   'accesscode': 'APP-1-1234567890'})
     206        self.assertEqual(result, {'accesscode': 'APP-1-1234567890'})
    252207        return
    253208
Note: See TracChangeset for help on using the changeset viewer.