def test_locale_url(): rf = test_utils.RequestFactory() request = rf.get('/de', SCRIPT_NAME='/z') prefixer = urlresolvers.Prefixer(request) urlresolvers.set_url_prefix(prefixer) s = render('{{ locale_url("mobile") }}') eq_(s, '/z/de/mobile')
def test_script_name(self): rf = RequestFactory() request = rf.get('/foo', SCRIPT_NAME='/oremj') prefixer = urlresolvers.Prefixer(request) eq_(prefixer.fix(prefixer.shortened_path), '/oremj/en-US/firefox/foo') # Now check reverse. urlresolvers.set_url_prefix(prefixer) set_script_prefix('/oremj') eq_(urlresolvers.reverse('home'), '/oremj/en-US/firefox/')
def test_fix(self): rf = RequestFactory() prefixer = urlresolvers.Prefixer(rf.get('/')) eq_(prefixer.fix('/'), '/en-US/firefox/') eq_(prefixer.fix('/foo'), '/en-US/firefox/foo') eq_(prefixer.fix('/foo/'), '/en-US/firefox/foo/') eq_(prefixer.fix('/admin'), '/en-US/admin') eq_(prefixer.fix('/admin/'), '/en-US/admin/') prefixer.locale = 'de' prefixer.app = 'thunderbird' eq_(prefixer.fix('/'), '/de/thunderbird/') eq_(prefixer.fix('/foo'), '/de/thunderbird/foo') eq_(prefixer.fix('/foo/'), '/de/thunderbird/foo/') eq_(prefixer.fix('/admin'), '/de/admin') eq_(prefixer.fix('/admin/'), '/de/admin/')
def split_eq(url, locale, app, path): rf = RequestFactory() prefixer = urlresolvers.Prefixer(rf.get(url)) actual = (prefixer.locale, prefixer.app, prefixer.shortened_path) eq_(actual, (locale, app, path))
def test_app_preview(self): rf = test_utils.RequestFactory() request = rf.get('/') prefixer = urlresolvers.Prefixer(request) eq_(prefixer.fix(prefixer.shortened_path), '/en-US/apps/')