PageRenderTime 29ms CodeModel.GetById 8ms RepoModel.GetById 0ms app.codeStats 0ms

/tests/regressiontests/views/tests/specials.py

https://code.google.com/p/mango-py/
Python | 35 lines | 12 code | 5 blank | 18 comment | 0 complexity | 7cb1a1d1299e6b0ab52524e0f900b18f MD5 | raw file
Possible License(s): BSD-3-Clause
  1. # coding: utf-8
  2. from django.test import TestCase
  3. class URLHandling(TestCase):
  4. """
  5. Tests for URL handling in views and responses.
  6. """
  7. redirect_target = "/views/%E4%B8%AD%E6%96%87/target/"
  8. def test_combining_redirect(self):
  9. """
  10. Tests that redirecting to an IRI, requiring encoding before we use it
  11. in an HTTP response, is handled correctly. In this case the arg to
  12. HttpRedirect is ASCII but the current request path contains non-ASCII
  13. characters so this test ensures the creation of the full path with a
  14. base non-ASCII part is handled correctly.
  15. """
  16. response = self.client.get(u'/views/中?–‡/')
  17. self.assertRedirects(response, self.redirect_target)
  18. def test_nonascii_redirect(self):
  19. """
  20. Tests that a non-ASCII argument to HttpRedirect is handled properly.
  21. """
  22. response = self.client.get('/views/nonascii_redirect/')
  23. self.assertRedirects(response, self.redirect_target)
  24. def test_permanent_nonascii_redirect(self):
  25. """
  26. Tests that a non-ASCII argument to HttpPermanentRedirect is handled
  27. properly.
  28. """
  29. response = self.client.get('/views/permanent_nonascii_redirect/')
  30. self.assertRedirects(response, self.redirect_target, status_code=301)