You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
1.2 KiB

10 years ago
10 years ago
10 years ago
  1. from django.test import TestCase
  2. from django.test.utils import override_settings
  3. class BasicsTestCase(TestCase):
  4. @override_settings(DEBUG=False, SECRET_KEY="abc")
  5. def test_it_redirects_to_login(self):
  6. r = self.client.get("/")
  7. self.assertRedirects(r, "/accounts/login/")
  8. @override_settings(DEBUG=False, SECRET_KEY="abc")
  9. def test_it_shows_no_warning(self):
  10. r = self.client.get("/accounts/login/")
  11. self.assertContains(r, "Sign In to", status_code=200)
  12. self.assertNotContains(r, "do not use in production")
  13. @override_settings(DEBUG=True, SECRET_KEY="abc")
  14. def test_it_shows_debug_warning(self):
  15. r = self.client.get("/accounts/login/")
  16. self.assertContains(r, "Running in debug mode")
  17. @override_settings(DEBUG=False, SECRET_KEY="---")
  18. def test_it_shows_secret_key_warning(self):
  19. r = self.client.get("/accounts/login/")
  20. self.assertContains(r, "Sign In to", status_code=200)
  21. self.assertContains(r, "Running with an insecure SECRET_KEY value")
  22. @override_settings(REGISTRATION_OPEN=False)
  23. def test_it_obeys_registration_open(self):
  24. r = self.client.get("/accounts/login/")
  25. self.assertNotContains(r, "Sign Up")