def accept_check(x, y): return eq_(lang_from_accept_header(x), y)
for method in ('get', 'head', 'options'): res = getattr(self.client, method)('/robots.txt?cache=1') self._test_headers_set(res, max_age=self.CACHE_DURATION) # We can never get a lower max-age than CACHE_MIDDLEWARE_SECONDS # as long as we request caching headers to be set. res = getattr(self.client, method)('/robots.txt?cache=60') self._test_headers_set(res, max_age=self.CACHE_DURATION) @override_settings(CACHE_MIDDLEWARE_SECONDS=CACHE_DURATION, USE_ETAGS=True) def test_headers_set_and_long_cache_requested(self): for method in ('get', 'head', 'options'): res = getattr(self.client, method)('/robots.txt?cache=21600') self._test_headers_set(res, max_age=21600) accept_check = lambda x, y: eq_(lang_from_accept_header(x), y) def test_parse_accept_language(): expected = 'ga-IE', 'zh-TW', 'zh-CN', 'en-US', 'fr' for lang in expected: assert lang in settings.AMO_LANGUAGES, lang d = (('ga-ie', 'ga-IE'), # Capitalization is no big deal. ('ga-IE', 'ga-IE'), ('GA-ie', 'ga-IE'), # Go for something less specific. ('fr-FR', 'fr'), # Go for something more specific. ('ga', 'ga-IE'), ('ga-XX', 'ga-IE'),