diff options
| author | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2007-11-28 21:51:17 +0000 |
|---|---|---|
| committer | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2007-11-28 21:51:17 +0000 |
| commit | a97abcffc27c5026041afccb1d76f7e4e4b1df69 (patch) | |
| tree | c6abc02b4d90e83788f6d156ca8efecb25cbae1c /tests/regressiontests/cache | |
| parent | 5d85a5147b55cbe7940df2321e73c48ca265f649 (diff) | |
queryset-refactor: Merged from trunk up to [6724].
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@6726 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests/cache')
| -rw-r--r-- | tests/regressiontests/cache/tests.py | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/tests/regressiontests/cache/tests.py b/tests/regressiontests/cache/tests.py index 3879da7703..e94ea33139 100644 --- a/tests/regressiontests/cache/tests.py +++ b/tests/regressiontests/cache/tests.py @@ -3,9 +3,12 @@ # Unit tests for cache framework # Uses whatever cache backend is set in the test settings file. -from django.core.cache import cache import time, unittest +from django.core.cache import cache +from django.utils.cache import patch_vary_headers +from django.http import HttpResponse + # functions/classes for complex data type tests def f(): return 42 @@ -87,5 +90,30 @@ class Cache(unittest.TestCase): cache.set(key, value) self.assertEqual(cache.get(key), value) + +class CacheUtils(unittest.TestCase): + """TestCase for django.utils.cache functions.""" + + def test_patch_vary_headers(self): + headers = ( + # Initial vary, new headers, resulting vary. + (None, ('Accept-Encoding',), 'Accept-Encoding'), + ('Accept-Encoding', ('accept-encoding',), 'Accept-Encoding'), + ('Accept-Encoding', ('ACCEPT-ENCODING',), 'Accept-Encoding'), + ('Cookie', ('Accept-Encoding',), 'Cookie, Accept-Encoding'), + ('Cookie, Accept-Encoding', ('Accept-Encoding',), 'Cookie, Accept-Encoding'), + ('Cookie, Accept-Encoding', ('Accept-Encoding', 'cookie'), 'Cookie, Accept-Encoding'), + (None, ('Accept-Encoding', 'COOKIE'), 'Accept-Encoding, COOKIE'), + ('Cookie, Accept-Encoding', ('Accept-Encoding', 'cookie'), 'Cookie, Accept-Encoding'), + ('Cookie , Accept-Encoding', ('Accept-Encoding', 'cookie'), 'Cookie, Accept-Encoding'), + ) + for initial_vary, newheaders, resulting_vary in headers: + response = HttpResponse() + if initial_vary is not None: + response['Vary'] = initial_vary + patch_vary_headers(response, newheaders) + self.assertEqual(response['Vary'], resulting_vary) + + if __name__ == '__main__': unittest.main() |
