diff options
author | Matthew Lemon <lemon@matthewlemon.com> | 2020-05-26 19:01:08 +0100 |
---|---|---|
committer | Matthew Lemon <lemon@matthewlemon.com> | 2020-05-26 19:01:08 +0100 |
commit | 01e62383a91ca5888631a78a16de16beb2aea164 (patch) | |
tree | 20d1e7d6cfe8e7637aa36d16c7af869a43a81af8 /ctrack | |
parent | 1f6d284eda9c9d08fc3b805f751398f937961eb1 (diff) |
functional test for basic user log in passing
Diffstat (limited to '')
-rw-r--r-- | ctrack/templates/account/login.html | 2 | ||||
-rw-r--r-- | ctrack/users/tests/test_functional.py | 26 |
2 files changed, 25 insertions, 3 deletions
diff --git a/ctrack/templates/account/login.html b/ctrack/templates/account/login.html index bb261f4..f395478 100644 --- a/ctrack/templates/account/login.html +++ b/ctrack/templates/account/login.html @@ -38,7 +38,7 @@ for a {{ site_name }} account and sign in below:{% endblocktrans %}</p> <input type="hidden" name="{{ redirect_field_name }}" value="{{ redirect_field_value }}" /> {% endif %} <a class="button secondaryAction" href="{% url 'account_reset_password' %}">{% trans "Forgot Password?" %}</a> - <button class="primaryAction btn btn-primary" type="submit">{% trans "Sign In" %}</button> + <button class="primaryAction btn btn-primary" id="sign_in_button" type="submit">{% trans "Sign In" %}</button> </form> {% endblock %} 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}/") |