aboutsummaryrefslogtreecommitdiff
path: root/tests/test_auth.py
diff options
context:
space:
mode:
authorDennis Fink2026-11-14 19:43:28 +0100
committerDennis Fink2026-11-14 19:43:28 +0100
commitc74feda222745ab7cca8993df83d9ea5f9d07e5b (patch)
treeacc7bf9bd7223f9d685d6c2954c5c90d7a9e36f0 /tests/test_auth.py
parente52e554e2d033dd5ef8397617644e90e354f9560 (diff)
downloadwebmentions-ssg-c74feda222745ab7cca8993df83d9ea5f9d07e5b.tar.gz
webmentions-ssg-c74feda222745ab7cca8993df83d9ea5f9d07e5b.zip
refactor(core): use HTTPStatus consistently
Replace numeric HTTP response and assertion codes in views and tests with `HTTPStatus` members so status handling is more descriptive and consistent.
Diffstat (limited to '')
-rw-r--r--tests/test_auth.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/tests/test_auth.py b/tests/test_auth.py
index bc951b9..3b05b6f 100644
--- a/tests/test_auth.py
+++ b/tests/test_auth.py
@@ -4,6 +4,8 @@
"""Test the session user loader."""
+from http import HTTPStatus
+
import pytest
from flask import Flask
@@ -94,8 +96,8 @@ def test_password_change_invalidates_existing_session(app: Flask) -> None:
response = client.post(
"/login", data={"username": "account", "password": old_password}
)
- assert response.status_code == 302
- assert client.get("/received").status_code == 200
+ assert response.status_code == HTTPStatus.FOUND
+ assert client.get("/received").status_code == HTTPStatus.OK
with client.session_transaction() as session:
assert session["_user_id"] == old_identifier
@@ -113,14 +115,14 @@ def test_password_change_invalidates_existing_session(app: Flask) -> None:
assert load_user(user.get_id()) is user
# A pre-existing, validly signed cookie no longer authenticates.
- assert client.get("/received").status_code == 302
+ assert client.get("/received").status_code == HTTPStatus.FOUND
# Logging in with the newly chosen password still works.
response = client.post(
"/login", data={"username": "account", "password": new_password}
)
- assert response.status_code == 302
- assert client.get("/received").status_code == 200
+ assert response.status_code == HTTPStatus.FOUND
+ assert client.get("/received").status_code == HTTPStatus.OK
@pytest.mark.parametrize(