aboutsummaryrefslogtreecommitdiffstats
path: root/ctrack/users
diff options
context:
space:
mode:
authorMatthew Lemon <lemon@matthewlemon.com>2020-05-26 19:01:08 +0100
committerMatthew Lemon <lemon@matthewlemon.com>2020-05-26 19:01:08 +0100
commit01e62383a91ca5888631a78a16de16beb2aea164 (patch)
tree20d1e7d6cfe8e7637aa36d16c7af869a43a81af8 /ctrack/users
parent1f6d284eda9c9d08fc3b805f751398f937961eb1 (diff)
functional test for basic user log in passing
Diffstat (limited to 'ctrack/users')
-rw-r--r--ctrack/users/tests/test_functional.py26
1 files changed, 24 insertions, 2 deletions
diff --git a/ctrack/users/tests/test_functional.py b/ctrack/users/tests/test_functional.py
index 6403d0b..2ba5faf 100644
--- a/ctrack/users/tests/test_functional.py
+++ b/ctrack/users/tests/test_functional.py
@@ -1,12 +1,34 @@
+"""
+Functional tests. Are probably SLOW thanks to using Selenium to load a browser instance.
+
+The use case being tested here is related to a user being able to log in and hit
+the correct page, containing their details. Those details depend on whether they are
+a regular user or a stakeholder user.
+"""
+
+import time
+
import pytest
from ctrack.organisations.models import Stakeholder
+from ctrack.users.models import User
pytestmark = pytest.mark.django_db
-def test_profile_page_html(person, user, browser):
+def test_user_can_log_in(browser, live_server):
+ User.objects.create_user(username="toss", password="knob")
+ browser.get(live_server + "/accounts/login")
+ browser.find_element_by_id("id_login").send_keys("toss")
+ browser.find_element_by_id("id_password").send_keys("knob")
+ browser.find_element_by_id("sign_in_button").submit()
+ time.sleep(1)
+ current_url = browser.current_url
+ assert current_url == live_server + "/users/toss/"
+
+
+def test_profile_page_html(person, user, browser, live_server):
stakeholder = Stakeholder.objects.create(person=person)
user.stakeholder = stakeholder
user.save()
- browser.get(f"http://localhost:8000/users/{user.username}")
+ browser.get(live_server + f"/users/{user.username}/")