Skip to content
This repository has been archived by the owner on Dec 18, 2024. It is now read-only.

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Dec 2, 2024
1 parent 289b5c4 commit 7d9b944
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 24 deletions.
16 changes: 10 additions & 6 deletions api/sso/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,23 @@ def logout_get(self):
"""GET /sso/logout endpoint"""
post_logout_redirect_uri = request.args.get(
"post_logout_redirect_uri",
Config.SSO_POST_SIGN_OUT_URL + f"?{urlencode({'return_app': session['return_app']})}"
if "return_app" in session
else "",
(
Config.SSO_POST_SIGN_OUT_URL + f"?{urlencode({'return_app': session['return_app']})}"
if "return_app" in session
else ""
),
)
return SsoView.logout(post_logout_redirect_uri)

def logout_post(self):
"""POST /sso/logout endpoint"""
post_logout_redirect_uri = request.form.get(
"post_logout_redirect_uri",
Config.SSO_POST_SIGN_OUT_URL + f"?{urlencode({'return_app': session['return_app']})}"
if "return_app" in session
else "",
(
Config.SSO_POST_SIGN_OUT_URL + f"?{urlencode({'return_app': session['return_app']})}"
if "return_app" in session
else ""
),
)
return SsoView.logout(post_logout_redirect_uri)

Expand Down
24 changes: 13 additions & 11 deletions tests/test_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,19 @@ def mock_get_account(mocker, request):

mocker.patch(
"models.account.AccountMethods.get_account",
return_value=Account.from_json(
{
"account_id": test_user_id,
"email_address": test_user_email,
"full_name": test_user_full_name,
"azure_ad_subject_id": azure_ad_subject_id,
"roles": roles,
}
)
if not new_account
else None,
return_value=(
Account.from_json(
{
"account_id": test_user_id,
"email_address": test_user_email,
"full_name": test_user_full_name,
"azure_ad_subject_id": azure_ad_subject_id,
"roles": roles,
}
)
if not new_account
else None
),
)
yield

Expand Down
13 changes: 8 additions & 5 deletions tests/test_magic_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,10 @@ def test_reused_magic_link_with_active_session_shows_landing(self, flask_test_cl
use_endpoint = f"/magic-links/{link_key}"
landing_endpoint = f"/service/magic-links/landing/{link_key}?fund=cof&round=r2w3"

with mock.patch("models.fund.FundMethods.get_fund") as mock_get_fund, mock.patch(
"frontend.magic_links.routes.get_round_data"
) as mock_get_round_data:
with (
mock.patch("models.fund.FundMethods.get_fund") as mock_get_fund,
mock.patch("frontend.magic_links.routes.get_round_data") as mock_get_round_data,
):
# Mock get_fund() called in get_magic_link()
mock_fund = mock.MagicMock()
mock_fund.configure_mock(name="cof")
Expand Down Expand Up @@ -226,8 +227,10 @@ def test_search_magic_link_forbidden_on_production(self, flask_test_client):
assert response.status_code == 403

def test_search_magic_link_returns_magic_links(self, flask_test_client):
with mock.patch("models.fund.FundMethods.get_fund"), mock.patch("models.account.get_round_data"), mock.patch(
"frontend.magic_links.routes.get_round_data"
with (
mock.patch("models.fund.FundMethods.get_fund"),
mock.patch("models.account.get_round_data"),
mock.patch("frontend.magic_links.routes.get_round_data"),
):
payload = {
"email": "new_user@example.com",
Expand Down
3 changes: 1 addition & 2 deletions tests/test_sso.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,7 @@ def test_sso_get_token_prevents_overwrite_of_existing_azure_subject_id(flask_tes
assert (
"Cannot update account id: usersso - "
"attempting to update existing azure_ad_subject_id "
"from abc to xyx which is not allowed."
in caplog.text
"from abc to xyx which is not allowed." in caplog.text
)


Expand Down

0 comments on commit 7d9b944

Please sign in to comment.