aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ctrack/conftest.py7
-rw-r--r--ctrack/users/tests/test_functional.py6
-rw-r--r--ctrack/users/tests/test_views.py9
3 files changed, 14 insertions, 8 deletions
diff --git a/ctrack/conftest.py b/ctrack/conftest.py
index 7d1d9e2..37a4a6c 100644
--- a/ctrack/conftest.py
+++ b/ctrack/conftest.py
@@ -10,6 +10,7 @@ from ctrack.organisations.models import (
AddressType,
Mode,
Organisation,
+ Stakeholder,
Submode,
)
from ctrack.organisations.tests.factories import (
@@ -61,6 +62,12 @@ def addr() -> Address:
@pytest.fixture
+def stakeholder(person):
+ s = Stakeholder.objects.create(person=person)
+ return s
+
+
+@pytest.fixture
def request_factory() -> RequestFactory:
return RequestFactory()
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("/")