<s> from django . test import TestCase , RequestFactory <EOL> from django . test . utils import override_settings <EOL> from funfactory . middleware import LocaleURLMiddleware <EOL> class TestLocaleURLMiddleware ( TestCase ) : <EOL> def setUp ( self ) : <EOL> self . rf = RequestFactory ( ) <EOL> self . middleware = LocaleURLMiddleware ( ) <EOL> @ override_settings ( DEV_LANGUAGES = ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> FF_EXEMPT_LANG_PARAM_URLS = ( ) ) <EOL> def test_redirects_to_correct_language ( self ) : <EOL> """<STR_LIT>""" <EOL> path = '<STR_LIT>' <EOL> req = self . rf . get ( path , HTTP_ACCEPT_LANGUAGE = '<STR_LIT>' ) <EOL> resp = LocaleURLMiddleware ( ) . process_request ( req ) <EOL> self . assertEqual ( resp [ '<STR_LIT>' ] , '<STR_LIT>' + path ) <EOL> @ override_settings ( DEV_LANGUAGES = ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> LANGUAGE_CODE = '<STR_LIT>' , <EOL> FF_EXEMPT_LANG_PARAM_URLS = ( ) ) <EOL> def test_redirects_to_default_language ( self ) : <EOL> """<STR_LIT>""" <EOL> path = '<STR_LIT>' <EOL> req = self . rf . get ( path , HTTP_ACCEPT_LANGUAGE = '<STR_LIT>' ) <EOL> resp = LocaleURLMiddleware ( ) . process_request ( req ) <EOL> self . assertEqual ( resp [ '<STR_LIT>' ] , '<STR_LIT>' + path ) <EOL> @ override_settings ( DEV_LANGUAGES = ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> FF_EXEMPT_LANG_PARAM_URLS = ( '<STR_LIT>' , ) ) <EOL> def test_redirects_lang_param ( self ) : <EOL> """<STR_LIT>""" <EOL> path = '<STR_LIT>' <EOL> req = self . rf . get ( path , { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> resp = LocaleURLMiddleware ( ) . process_request ( req ) <EOL> self . assertEqual ( resp [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> @ override_settings ( DEV_LANGUAGES = ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> FF_EXEMPT_LANG_PARAM_URLS = ( '<STR_LIT>' , ) ) <EOL> def test_no_redirect_lang_param ( self ) : <EOL> """<STR_LIT>""" <EOL> path = '<STR_LIT>' <EOL> req = self . rf . get ( path , { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> resp = LocaleURLMiddleware ( ) . process_request ( req ) <EOL> self . assertIs ( resp , None ) </s>
