diff options
author | Matthew Lemon <lemon@matthewlemon.com> | 2020-05-26 21:22:51 +0100 |
---|---|---|
committer | Matthew Lemon <lemon@matthewlemon.com> | 2020-05-26 21:22:51 +0100 |
commit | ca2272bca90fc1fb7dbd78a2458ae921d5ffa59e (patch) | |
tree | 415fe963685c3ea3573a094b12d1e4d16e9c2664 /ctrack/users | |
parent | 055f13ec1a20a2043daee6c7784045ae06e92236 (diff) |
regular user goes to regular user home page template when logging in
Diffstat (limited to 'ctrack/users')
-rw-r--r-- | ctrack/users/tests/test_functional.py | 4 | ||||
-rw-r--r-- | ctrack/users/tests/test_views.py | 16 |
2 files changed, 19 insertions, 1 deletions
diff --git a/ctrack/users/tests/test_functional.py b/ctrack/users/tests/test_functional.py index 18dd477..c68382c 100644 --- a/ctrack/users/tests/test_functional.py +++ b/ctrack/users/tests/test_functional.py @@ -38,3 +38,7 @@ def test_user_can_log_in(browser, person, live_server): # Such as his own name in an H1 tag! h1 = browser.find_element_by_tag_name("h1") assert h1.text == "Welcome to ctrack - Department for Transport" + type_user_message = browser.find_elements_by_tag_name("p") + assert "THIS IS A TEMPLATE FOR A REGULAR USER" in [ + m.text for m in type_user_message + ] diff --git a/ctrack/users/tests/test_views.py b/ctrack/users/tests/test_views.py index da00a0d..6859215 100644 --- a/ctrack/users/tests/test_views.py +++ b/ctrack/users/tests/test_views.py @@ -84,7 +84,7 @@ def test_profile_view_contains_organisation_information(person, user): assert response.context_data["user"].stakeholder.person.first_name == "Toss" -def test_home_page_h1_tag_with_client(person, client, django_user_model): +def test_home_page_h1_tag_with_client(client, django_user_model): """ Basic test of HTML from the home page. """ @@ -96,3 +96,17 @@ def test_home_page_h1_tag_with_client(person, client, django_user_model): 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 + + +def test_regular_user_gets_regular_user_template(django_user_model): + """ + When a user logs in without a stakeholder mapping, they get sent to the regular user + template. + """ + user = django_user_model.objects.create_user(username="toss", password="knob") + factory = RequestFactory() + request = factory.get("/") + request.user = user + response = home_page(request) + assert response.status_code == 200 + assert b"<p>THIS IS A TEMPLATE FOR A REGULAR USER</p>" in response.content |