diff options
author | Matthew Lemon <lemon@matthewlemon.com> | 2020-05-29 13:22:56 +0100 |
---|---|---|
committer | Matthew Lemon <lemon@matthewlemon.com> | 2020-05-29 13:22:56 +0100 |
commit | 8edc6a41c160ff75e964db45371e4ae63fb68c17 (patch) | |
tree | 6c5d941aa842dc75ae3939d56de1020c13320467 /ctrack/users/tests | |
parent | 2fd651e2cb3a4cd3a31921032af0279d156dd053 (diff) |
a lot of time and effort looking for a bug with selenium that wasnt there
Diffstat (limited to 'ctrack/users/tests')
-rw-r--r-- | ctrack/users/tests/test_functional.py | 40 |
1 files changed, 15 insertions, 25 deletions
diff --git a/ctrack/users/tests/test_functional.py b/ctrack/users/tests/test_functional.py index 6ea818f..882c974 100644 --- a/ctrack/users/tests/test_functional.py +++ b/ctrack/users/tests/test_functional.py @@ -34,13 +34,12 @@ def test_regular_user_can_log_in(browser, live_server): ] -def test_stakeholder_can_log_in_and_see_their_home(browser, live_server, stakeholder): +def test_stakeholder_can_log_in_and_see_their_home( + browser, live_server, stakeholder_user +): # Toss McBride is an OES user. He logs into the system... - user = User.objects.create_user(username="toss", password="knob") - user.stakeholder = stakeholder - org = user.stakeholder.person.get_organisation_name() - user.save() + user = stakeholder_user 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") @@ -52,19 +51,16 @@ def test_stakeholder_can_log_in_and_see_their_home(browser, live_server, stakeho p_tags = browser.find_elements_by_tag_name("p") h2_tags = browser.find_elements_by_tag_name("h2") assert "THIS IS A TEMPLATE FOR A STAKEHOLDER USER" in [m.text for m in p_tags] - assert org in [m.text for m in h2_tags] + assert ( - f"{user.stakeholder.person.first_name} {user.stakeholder.person.last_name}" - in [m.text for m in p_tags] + f"{user.stakeholder.person.get_organisation_name()} {user.stakeholder.person.organisation.submode}" + in [m.text for m in h2_tags] ) def test_stakeholder_can_log_in_but_receieved_permisson_denied_when_off_piste( - browser, live_server, stakeholder + browser, live_server, stakeholder_user ): - user = User.objects.create_user(username="toss", password="knob") - user.stakeholder = stakeholder - user.save() 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") @@ -78,10 +74,9 @@ def test_stakeholder_can_log_in_but_receieved_permisson_denied_when_off_piste( def test_stakeholder_user_with_permissions_can_view_page( - browser, live_server, stakeholder + browser, live_server, stakeholder_user ): - user = User.objects.create_user(username="toss", password="knob") - user.stakeholder = stakeholder + user = stakeholder_user org_list_permission = Permission.objects.get(name="Can view organisation") # Add the permission to view an Organisation, which is set on OrganisationListView @@ -101,11 +96,8 @@ def test_stakeholder_user_with_permissions_can_view_page( def test_stakeholder_user_can_see_requisite_subtitles_on_home_page( - browser, live_server, stakeholder + browser, live_server, stakeholder_user ): - user = User.objects.create_user(username="toss", password="knob") - user.stakeholder = stakeholder - user.save() 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") @@ -119,24 +111,22 @@ def test_stakeholder_user_can_see_requisite_subtitles_on_home_page( h2 = browser.find_elements_by_tag_name("h2") assert "Incident Reporting" in [x.text for x in h2] - assert "Audits and Inspections" in [x.text for x in h2] + assert "Compliance Events" in [x.text for x in h2] assert "NIS systems" in [x.text for x in h2] assert "DfT Engagement" in [x.text for x in h2] def test_stakeholder_logs_into_system_and_submits_incident_form( - browser, live_server, stakeholder + browser, live_server, stakeholder_user ): - user = User.objects.create_user(username="toss", password="knob") - user.stakeholder = stakeholder - user.save() + user = stakeholder_user 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 - browser.get(current_url) + assert current_url == live_server + "/" # Clicks the Report a NIS incident button browser.find_element_by_id("id_submit_incident_button").submit() |