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.

27 lines
1006 B

10 years ago
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_shows_welcome(self):
  6. r = self.client.get("/")
  7. self.assertContains(r, "Get Notified", status_code=200)
  8. self.assertNotContains(r, "do not use in production")
  9. @override_settings(DEBUG=True, SECRET_KEY="abc")
  10. def test_it_shows_debug_warning(self):
  11. r = self.client.get("/")
  12. self.assertContains(r, "Running in debug mode")
  13. @override_settings(DEBUG=False, SECRET_KEY="---")
  14. def test_it_shows_secret_key_warning(self):
  15. r = self.client.get("/")
  16. self.assertContains(r, "Get Notified", status_code=200)
  17. self.assertContains(r, "Running with an insecure SECRET_KEY value")
  18. @override_settings(REGISTRATION_OPEN=False)
  19. def test_it_obeys_registration_open(self):
  20. r = self.client.get("/")
  21. self.assertNotContains(r, "Get Started")