diff options
Diffstat (limited to '')
| -rw-r--r-- | tests/test_models.py | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/tests/test_models.py b/tests/test_models.py index b9e7c80..85c216e 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -5,11 +5,13 @@ import uuid from collections.abc import Callable from datetime import UTC, datetime +from typing import get_type_hints import pytest import sqlalchemy as sa from flask import Flask from sqlalchemy.exc import IntegrityError +from sqlalchemy.orm import Mapped from webmentions_ssg import db from webmentions_ssg.models import ( @@ -24,6 +26,19 @@ from webmentions_ssg.models import ( ) +def test_uuid_annotations_and_relationships_resolve() -> None: + """Keep UUID columns and forward relationships mapped without future annotations.""" + for model in (ReceivedWebmention, Source, SentWebmention): + assert get_type_hints(model)["uuid"] == Mapped[uuid.UUID] + assert sa.inspect(model).columns["uuid"].primary_key + + assert ( + sa.inspect(Source).relationships["sent_webmentions"].mapper.class_ + is SentWebmention + ) + assert sa.inspect(SentWebmention).relationships["source"].mapper.class_ is Source + + def test_user_repr() -> None: user = User(username="admin", password="secret") assert repr(user) == "<User admin>" @@ -234,10 +249,13 @@ def test_received_status_round_trips_as_enum(app: Flask) -> None: db.session.add(mention) db.session.commit() - assert db.session.scalar( - sa.text("SELECT status FROM received_webmentions WHERE uuid = :uuid"), - {"uuid": identifier.hex}, - ) == "verified" + assert ( + db.session.scalar( + sa.text("SELECT status FROM received_webmentions WHERE uuid = :uuid"), + {"uuid": identifier.hex}, + ) + == "verified" + ) db.session.expunge_all() loaded = db.session.get(ReceivedWebmention, identifier) @@ -287,7 +305,6 @@ def test_reopen_preserves_delivery_history() -> None: assert mention.sent_revision == 2 - def test_resend_requeues_current_revision_without_losing_send_history() -> None: from webmentions_ssg.models import SentWebmentionStatus |
