From dc5a5fd8afeed237e4ac4fe24391d84e6a2095bc Mon Sep 17 00:00:00 2001 From: D C <137912394+CrzyHAX91@users.noreply.github.com> Date: Wed, 27 Nov 2024 00:32:42 +0100 Subject: [PATCH] test.vieuws.py update --- dropship_project/test_views.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/dropship_project/test_views.py b/dropship_project/test_views.py index cca0cac0..71506500 100644 --- a/dropship_project/test_views.py +++ b/dropship_project/test_views.py @@ -24,14 +24,22 @@ def test_home_view(self): self.assertContains(response, 'Welcome to Dropship V2') def test_dashboard_view(self): - self.client.login(username='testuser', password='testpassword') + self.client.force_login(self.user) response = self.client.get(reverse('user_dashboard')) self.assertEqual(response.status_code, 200) self.assertContains(response, 'User Dashboard') def test_profile_view(self): - self.client.login(username='testuser', password='testpassword') + self.client.force_login(self.user) response = self.client.get(reverse('user_profile')) self.assertEqual(response.status_code, 200) self.assertContains(response, 'User Profile') + def test_login_required_dashboard(self): + response = self.client.get(reverse('user_dashboard')) + self.assertRedirects(response, f'{reverse("account_login")}?next={reverse("user_dashboard")}') + + def test_login_required_profile(self): + response = self.client.get(reverse('user_profile')) + self.assertRedirects(response, f'{reverse("account_login")}?next={reverse("user_profile")}') +