diff options
author | Matthew Lemon <lemon@matthewlemon.com> | 2020-05-26 20:57:57 +0100 |
---|---|---|
committer | Matthew Lemon <lemon@matthewlemon.com> | 2020-05-26 20:57:57 +0100 |
commit | ab83194ae6b0aeadd57237d32eb08d7c09e703b3 (patch) | |
tree | c4488f77d24a94ab075b6b6f33173734c1ab626e /ctrack/users/tests | |
parent | 4c96bc3475ba0c97f815a050e79d7983d76233cf (diff) |
when user logs in - now redirects to home page - func and unit tests passing
Diffstat (limited to 'ctrack/users/tests')
-rw-r--r-- | ctrack/users/tests/test_functional.py | 7 | ||||
-rw-r--r-- | ctrack/users/tests/test_views.py | 18 |
2 files changed, 18 insertions, 7 deletions
diff --git a/ctrack/users/tests/test_functional.py b/ctrack/users/tests/test_functional.py index 8fcc285..18dd477 100644 --- a/ctrack/users/tests/test_functional.py +++ b/ctrack/users/tests/test_functional.py @@ -30,10 +30,11 @@ def test_user_can_log_in(browser, person, live_server): browser.find_element_by_id("sign_in_button").submit() time.sleep(1) current_url = browser.current_url - assert current_url == live_server + "/users/toss/" + assert current_url == live_server + "/" # On the other side, he sees some basic details about himself. - assert "User: toss" in browser.title + assert "ctrack - Department for Transport" in browser.title # Such as his own name in an H1 tag! - assert browser.find_element_by_tag_name("H1") == "Toss McBride" + h1 = browser.find_element_by_tag_name("h1") + assert h1.text == "Welcome to ctrack - Department for Transport" diff --git a/ctrack/users/tests/test_views.py b/ctrack/users/tests/test_views.py index 2aa463e..da00a0d 100644 --- a/ctrack/users/tests/test_views.py +++ b/ctrack/users/tests/test_views.py @@ -1,8 +1,10 @@ import pytest from django.contrib.auth import get_user_model +from django.http import HttpRequest from django.test import RequestFactory from django.urls import resolve +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 @@ -82,7 +84,15 @@ def test_profile_view_contains_organisation_information(person, user): assert response.context_data["user"].stakeholder.person.first_name == "Toss" -def test_user_page_has_h1_with_their_name_in_it(person, user): - """Test""" - # TODO - write this test; it will make part of func test pass. - found = resolve("/") +def test_home_page_h1_tag_with_client(person, client, django_user_model): + """ + Basic test of HTML from the home page. + """ + django_user_model.objects.create_user(username="toss", password="knob") + client.login(username="toss", password="knob") + response = client.get("/") + assert response.status_code == 200 + assert response.content[:15] == b"<!DOCTYPE html>" + assert b"<title>ctrack - Department for Transport</title>" in response.content + assert b"<h1>Welcome to ctrack - Department for Transport</h1>" in response.content + assert b"</html>" in response.content |