From ed9a9be6e9daf58ef445047a85d0748fef53087f Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Wed, 27 May 2020 15:05:46 +0100 Subject: further refactor --- ctrack/users/tests/test_functional.py | 6 +++--- ctrack/users/tests/test_views.py | 9 ++++----- 2 files changed, 7 insertions(+), 8 deletions(-) (limited to 'ctrack/users') diff --git a/ctrack/users/tests/test_functional.py b/ctrack/users/tests/test_functional.py index d5390f6..1edb17e 100644 --- a/ctrack/users/tests/test_functional.py +++ b/ctrack/users/tests/test_functional.py @@ -10,7 +10,6 @@ import time import pytest -from ctrack.organisations.models import Stakeholder from ctrack.users.models import User pytestmark = pytest.mark.django_db @@ -39,9 +38,10 @@ def test_regular_user_can_log_in(browser, person, live_server): ] -def test_stakeholder_can_log_in_and_see_their_home(browser, person, live_server): +def test_stakeholder_can_log_in_and_see_their_home( + browser, person, live_server, stakeholder +): # Toss McBride is an OES user. He logs into the system... - stakeholder = Stakeholder.objects.create(person=person) user = User.objects.create_user(username="toss", password="knob") user.stakeholder = stakeholder diff --git a/ctrack/users/tests/test_views.py b/ctrack/users/tests/test_views.py index e8664df..6f458a3 100644 --- a/ctrack/users/tests/test_views.py +++ b/ctrack/users/tests/test_views.py @@ -2,7 +2,6 @@ import pytest from django.test import RequestFactory from ctrack.core.views import home_page -from ctrack.organisations.models import Stakeholder from ctrack.users.models import User from ctrack.users.views import UserDetailView, UserRedirectView, UserUpdateView @@ -48,13 +47,14 @@ class TestUserRedirectView: assert view.get_redirect_url() == "/" -def test_profile_view_contains_organisation_information(person, user, request_factory): +def test_profile_view_contains_organisation_information( + person, user, request_factory, stakeholder +): """ This tests the context_data - not the rendered page... We'll do that in the next test. """ org_name = person.organisation.name - stakeholder = Stakeholder.objects.create(person=person) user.stakeholder = stakeholder user.save() request = request_factory.get(f"/users/{user.username}") @@ -110,14 +110,13 @@ def test_regular_user_redirected_to_their_template_on_login( def test_stakeholder_redirected_to_their_template_on_login( - django_user_model, person, request_factory: RequestFactory + django_user_model, person, request_factory: RequestFactory, stakeholder ): """ When a user logs in WITH a stakeholder mapping, they get sent to the stakehoder user template. """ user = django_user_model.objects.create_user(username="toss", password="knob") - stakeholder = Stakeholder.objects.create(person=person) user.stakeholder = stakeholder user.save() request = request_factory.get("/") -- cgit v1.2.3