aboutsummaryrefslogtreecommitdiffstats
path: root/ctrack
diff options
context:
space:
mode:
Diffstat (limited to 'ctrack')
-rw-r--r--ctrack/conftest.py15
-rw-r--r--ctrack/core/tests/test_functional.py11
-rw-r--r--ctrack/users/tests/test_functional.py12
-rw-r--r--ctrack/users/tests/test_views.py7
4 files changed, 29 insertions, 16 deletions
diff --git a/ctrack/conftest.py b/ctrack/conftest.py
index 4fef7a9..efbb4ef 100644
--- a/ctrack/conftest.py
+++ b/ctrack/conftest.py
@@ -1,5 +1,9 @@
+import os
+
import pytest
from django.test import RequestFactory
+from selenium import webdriver
+from selenium.webdriver.firefox.options import Options
from ctrack.organisations.models import (
Address,
@@ -58,3 +62,14 @@ def addr() -> Address:
@pytest.fixture
def request_factory() -> RequestFactory:
return RequestFactory()
+
+
+@pytest.fixture(scope="module")
+def browser(request):
+ "Provide selenium webdriver instance."
+ os.environ["PATH"] += os.pathsep + os.getcwd()
+ options = Options()
+ options.headless = True
+ browser_ = webdriver.Firefox(firefox_options=options)
+ yield browser_
+ browser_.quit()
diff --git a/ctrack/core/tests/test_functional.py b/ctrack/core/tests/test_functional.py
index a802f22..6661072 100644
--- a/ctrack/core/tests/test_functional.py
+++ b/ctrack/core/tests/test_functional.py
@@ -1,14 +1,3 @@
-import pytest
-from selenium import webdriver
-
-
-@pytest.fixture
-def browser():
- b = webdriver.Firefox()
- yield b
- b.quit()
-
-
def test_can_get_homepage(browser):
browser.get("http://localhost:8000")
assert "ctrack" in browser.title
diff --git a/ctrack/users/tests/test_functional.py b/ctrack/users/tests/test_functional.py
new file mode 100644
index 0000000..6403d0b
--- /dev/null
+++ b/ctrack/users/tests/test_functional.py
@@ -0,0 +1,12 @@
+import pytest
+
+from ctrack.organisations.models import Stakeholder
+
+pytestmark = pytest.mark.django_db
+
+
+def test_profile_page_html(person, user, browser):
+ stakeholder = Stakeholder.objects.create(person=person)
+ user.stakeholder = stakeholder
+ user.save()
+ browser.get(f"http://localhost:8000/users/{user.username}")
diff --git a/ctrack/users/tests/test_views.py b/ctrack/users/tests/test_views.py
index 73d694c..0f57b36 100644
--- a/ctrack/users/tests/test_views.py
+++ b/ctrack/users/tests/test_views.py
@@ -48,14 +48,11 @@ class TestUserRedirectView:
assert view.get_redirect_url() == f"/users/{user.username}/"
-def test_profile_view_contains_organisation_information(person):
+def test_profile_view_contains_organisation_information(person, user):
"""url: users/username
This is where users are redirected to when they log in and where I want to capture
information about the user - particularly if they are an OES user.
"""
- user = get_user_model().objects.create_user(
- username="testy", email="testy@test.com", password="test1020"
- )
org_name = person.organisation.name
stakeholder = Stakeholder.objects.create(person=person)
user.stakeholder = stakeholder
@@ -71,7 +68,7 @@ def test_profile_view_contains_organisation_information(person):
response = UserDetailView.as_view()(request, username=user.username)
assert response.status_code == 200
- assert response.context_data["user"].username == "testy"
+ assert response.context_data["user"].username == user.username
assert response.context_data["user"].is_stakeholder() is True
assert response.context_data["user"].stakeholder.person.first_name == "Chinaplate"