From 292c97c64f7cc5197dfe7acb4355c7059f421583 Mon Sep 17 00:00:00 2001 From: Fred Pauchet Date: Thu, 6 Jan 2022 16:47:19 +0100 Subject: [PATCH] Make tests pass on home page --- config/settings.py | 2 +- ultron/core/tests.py | 18 +++++++++++++++++- ultron/people/tests.py | 6 ------ 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/config/settings.py b/config/settings.py index 01f935418d..4d99e6ce29 100644 --- a/config/settings.py +++ b/config/settings.py @@ -145,4 +145,4 @@ DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' # Simplified static file serving. # https://warehouse.python.org/project/whitenoise/ -STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' +#STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' diff --git a/ultron/core/tests.py b/ultron/core/tests.py index af52f94dd1..e11f0c31af 100644 --- a/ultron/core/tests.py +++ b/ultron/core/tests.py @@ -1,9 +1,25 @@ +from django.contrib.auth import get_user_model from django.test import TestCase from django.urls import reverse +USER = get_user_model() + + class HomeTests(TestCase): - def test_home_view_status_code(self): + def setUp(self): + self.user = USER.objects.create( + username="jbond", email="james@hms.co.uk", password="007" + ) + + def test_home_view_anonymous_redirected_statuts_code(self): url = reverse("home") response = self.client.get(url) + self.assertEquals(response.status_code, 302) + + def test_home_view_status_code_with_user_connected(self): + login_result = self.client.login(username="jbond", password="007") + + url = reverse("home") + response = self.client.get(url, follow=True) self.assertEquals(response.status_code, 200) diff --git a/ultron/people/tests.py b/ultron/people/tests.py index 681701d970..287e9d31bd 100644 --- a/ultron/people/tests.py +++ b/ultron/people/tests.py @@ -5,12 +5,6 @@ from django.urls import reverse from ultron.people.models import Gymnast -class HomeTests(TestCase): - def test_home_view_status_code(self): - url = reverse("home") - response = self.client.get(url) - self.assertEquals(response.status_code, 200) - class GymnastTestCase(TestCase): def test_gymnast_tostring(self):