Add non-prod banner

This commit is contained in:
Rachid Mrad 2024-02-02 15:11:22 -05:00
parent 10aa1c8e59
commit ad6d080ad9
No known key found for this signature in database
5 changed files with 93 additions and 29 deletions

View file

@ -0,0 +1,29 @@
from django.test import Client, TestCase, override_settings
from django.contrib.auth import get_user_model
class MyTestCase(TestCase):
def setUp(self):
self.client = Client()
username = "test_user"
first_name = "First"
last_name = "Last"
email = "info@example.com"
self.user = get_user_model().objects.create(
username=username, first_name=first_name, last_name=last_name, email=email
)
self.client.force_login(self.user)
def tearDown(self):
super().tearDown()
self.user.delete()
@override_settings(IS_PRODUCTION=True)
def test_production_environment(self):
home_page = self.client.get("/")
self.assertNotContains(home_page, "You are not on production.")
@override_settings(IS_PRODUCTION=False)
def test_non_production_environment(self):
home_page = self.client.get("/")
self.assertContains(home_page, "You are not on production.")