Fix failing tests

This includes a fix for the commit hash test, which was not referencing the Flask app in a valid way.

Signed-off-by: Carlo Costino <carlo.costino@gsa.gov>
This commit is contained in:
Carlo Costino
2024-03-19 15:53:38 -04:00
parent b4986e4170
commit 4b1db40cbd
3 changed files with 21 additions and 7 deletions

View File

@@ -221,7 +221,9 @@ def test_if_existing_user_accepts_twice_they_redirect_to_sign_in(
page.select("main p")[0].text.strip(),
) == (
"You need to sign in again",
"We signed you out because you have not used Notify for a while.",
# TODO: Improve this given Login.gov configuration.
# "We signed you out because you have not used Notify for a while.",
"You have left to use Login.gov to sign in",
)
# We dont let people update `email_access_validated_at` using an
# already-accepted invite
@@ -335,7 +337,9 @@ def test_existing_user_of_service_get_redirected_to_signin(
page.select("main p")[0].text.strip(),
) == (
"You need to sign in again",
"We signed you out because you have not used Notify for a while.",
# TODO: Improve this given Login.gov configuration.
# "We signed you out because you have not used Notify for a while.",
"You have left to use Login.gov to sign in",
)
assert mock_accept_invite.call_count == 1
@@ -424,7 +428,9 @@ def test_existing_signed_out_user_accept_invite_redirects_to_sign_in(
page.select("main p")[0].text.strip(),
) == (
"You need to sign in again",
"We signed you out because you have not used Notify for a while.",
# TODO: Improve this given Login.gov configuration.
# "We signed you out because you have not used Notify for a while.",
"You have left to use Login.gov to sign in",
)

View File

@@ -24,8 +24,11 @@ def test_render_sign_in_template_for_new_user(client_request):
# TODO: Fix this test to be less brittle! If the Login.gov link is enabled,
# then these indices need to be 1 instead of 0.
# Currently it's not enabled for the test or production environments.
assert page.select("main a")[0].text == "Forgot your password?"
assert page.select("main a")[0]["href"] == url_for("main.forgot_password")
assert page.select("main a")[1].text == "Forgot your password?"
assert page.select("main a")[1]["href"] == url_for("main.forgot_password")
# TODO: We'll have to adjust this depending on whether Login.gov is
# enabled or not; fix this in the future.
assert "Sign in again" not in normalize_spaces(page.text)

View File

@@ -1,6 +1,7 @@
import pytest
from flask import current_app
from flask import Flask
from app import create_app
from app.utils import merge_jsonlike
@@ -55,4 +56,8 @@ def test_merge_jsonlike_merges_jsonlike_objects_correctly(
def test_commit_hash():
# Assert that we have trimmed the default (unknown) commit hash to seven characters
# The real commit hash is supplied at deploy time.
assert current_app.config["COMMIT_HASH"] == "-------"
app = Flask("app")
create_app(app)
with app.app_context() as current_app:
assert current_app.app.config["COMMIT_HASH"] == "-------"