diff options
| author | Dennis Fink | 2026-10-30 11:51:34 +0100 |
|---|---|---|
| committer | Dennis Fink | 2026-10-30 11:51:34 +0100 |
| commit | 37bc3853dded34e3d1323874927979ce510e4910 (patch) | |
| tree | 7d6d2181d9bb05f4d4a8d00152c172cc92e7ab63 /tests/test_auth.py | |
| parent | 4485aeb573ceb37237ea1fbc80665ed6c4136116 (diff) | |
| download | webmentions-ssg-37bc3853dded34e3d1323874927979ce510e4910.tar.gz webmentions-ssg-37bc3853dded34e3d1323874927979ce510e4910.zip | |
test: align test suite with package structure
Diffstat (limited to 'tests/test_auth.py')
| -rw-r--r-- | tests/test_auth.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/test_auth.py b/tests/test_auth.py new file mode 100644 index 0000000..e0416b0 --- /dev/null +++ b/tests/test_auth.py @@ -0,0 +1,28 @@ +# SPDX-FileCopyrightText: 2026 Dennis Fink <me+coding@dennisfink.me> +# +# SPDX-License-Identifier: BSD-3-Clause + +"""Test the session user loader.""" + +from flask import Flask + +from webmentions_ssg import DATABASE as db +from webmentions_ssg.auth import AUTH, load_user +from webmentions_ssg.models import User + + +def test_user_loader_is_registered(app: Flask) -> None: + assert AUTH._user_callback is load_user + + +def test_load_user_returns_matching_user(app: Flask) -> None: + with app.app_context(): + user = User(username="account", password="secret") + db.session.add(user) + db.session.commit() + assert load_user(user.id) is user + + +def test_load_user_returns_none_for_unknown_id(app: Flask) -> None: + with app.app_context(): + assert load_user(99_999) is None |
