<s> import unittest <EOL> class TestDefaultRequestClassifier ( unittest . TestCase ) : <EOL> def _getFUT ( self ) : <EOL> from repoze . who . classifiers import default_request_classifier <EOL> return default_request_classifier <EOL> def _makeEnviron ( self , kw = None ) : <EOL> from wsgiref . util import setup_testing_defaults <EOL> environ = { } <EOL> setup_testing_defaults ( environ ) <EOL> if kw is not None : <EOL> environ . update ( kw ) <EOL> return environ <EOL> def test_conforms_to_IRequestClassifier ( self ) : <EOL> from repoze . who . interfaces import IRequestClassifier <EOL> self . assertTrue ( IRequestClassifier . providedBy ( self . _getFUT ( ) ) ) <EOL> def test_classify_dav_method ( self ) : <EOL> classifier = self . _getFUT ( ) <EOL> environ = self . _makeEnviron ( { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> result = classifier ( environ ) <EOL> self . assertEqual ( result , '<STR_LIT>' ) <EOL> def test_classify_dav_useragent ( self ) : <EOL> classifier = self . _getFUT ( ) <EOL> environ = self . _makeEnviron ( { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> result = classifier ( environ ) <EOL> self . assertEqual ( result , '<STR_LIT>' ) <EOL> def test_classify_xmlpost ( self ) : <EOL> classifier = self . _getFUT ( ) <EOL> environ = self . _makeEnviron ( { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:POST>' } ) <EOL> result = classifier ( environ ) <EOL> self . assertEqual ( result , '<STR_LIT>' ) <EOL> def test_classify_xmlpost_uppercase ( self ) : <EOL> """<STR_LIT>""" <EOL> classifier = self . _getFUT ( ) <EOL> environ = self . _makeEnviron ( { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:POST>' } ) <EOL> result = classifier ( environ ) <EOL> self . assertEqual ( result , '<STR_LIT>' ) <EOL> def test_classify_rich_xmlpost ( self ) : <EOL> """<STR_LIT>""" <EOL> classifier = self . _getFUT ( ) <EOL> environ = self . _makeEnviron ( { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:POST>' } ) <EOL> result = classifier ( environ ) <EOL> self . assertEqual ( result , '<STR_LIT>' ) <EOL> def test_classify_browser ( self ) : <EOL> classifier = self . _getFUT ( ) <EOL> environ = self . _makeEnviron ( { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:GET>' } ) <EOL> result = classifier ( environ ) <EOL> self . assertEqual ( result , '<STR_LIT>' ) <EOL> class TestDefaultChallengeDecider ( unittest . TestCase ) : <EOL> def _getFUT ( self ) : <EOL> from repoze . who . classifiers import default_challenge_decider <EOL> return default_challenge_decider <EOL> def test_conforms_to_IChallengeDecider ( self ) : <EOL> from repoze . who . interfaces import IChallengeDecider <EOL> self . assertTrue ( IChallengeDecider . providedBy ( self . _getFUT ( ) ) ) <EOL> def test_challenges_on_401 ( self ) : <EOL> decider = self . _getFUT ( ) <EOL> self . assertTrue ( decider ( { } , '<STR_LIT>' , [ ] ) ) <EOL> def test_doesnt_challenges_on_non_401 ( self ) : <EOL> decider = self . _getFUT ( ) <EOL> self . assertFalse ( decider ( { } , '<STR_LIT>' , [ ] ) ) <EOL> class TestPassthroughChallengeDecider ( unittest . TestCase ) : <EOL> def _getFUT ( self ) : <EOL> from repoze . who . classifiers import passthrough_challenge_decider <EOL> return passthrough_challenge_decider <EOL> def test_conforms_to_IChallengeDecider ( self ) : <EOL> from repoze . who . interfaces import IChallengeDecider <EOL> self . assertTrue ( IChallengeDecider . providedBy ( self . _getFUT ( ) ) ) <EOL> def test_challenges_on_bare_401 ( self ) : <EOL> decider = self . _getFUT ( ) <EOL> self . assertTrue ( decider ( { } , '<STR_LIT>' , [ ] ) ) <EOL> def test_doesnt_challenges_on_non_401 ( self ) : <EOL> decider = self . _getFUT ( ) <EOL> self . assertFalse ( decider ( { } , '<STR_LIT>' , [ ] ) ) <EOL> def test_doesnt_challenges_on_401_with_WWW_Authenticate ( self ) : <EOL> decider = self . _getFUT ( ) <EOL> self . assertFalse ( decider ( { } , '<STR_LIT>' , [ ( '<STR_LIT>' , '<STR_LIT>' ) ] ) ) <EOL> def test_doesnt_challenges_on_401_with_text_html ( self ) : <EOL> decider = self . _getFUT ( ) <EOL> self . assertFalse ( decider ( { } , '<STR_LIT>' , [ ( '<STR_LIT:Content-Type>' , '<STR_LIT>' ) ] ) ) </s>
