9e19c081b0
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
59 lines
1.7 KiB
Python
59 lines
1.7 KiB
Python
"""Smoke test for migration 0002: confirms model classes import and the
|
|
tag-kind uniqueness rule shape is correct.
|
|
"""
|
|
|
|
from backend.app.models import (
|
|
Base,
|
|
ImportBatch,
|
|
ImportSettings,
|
|
ImportTask,
|
|
Tag,
|
|
TagKind,
|
|
)
|
|
|
|
|
|
def test_new_tables_registered():
|
|
expected = {"import_batch", "import_task", "import_settings"}
|
|
assert expected.issubset(Base.metadata.tables.keys())
|
|
|
|
|
|
def test_tag_has_kind_and_fandom_id():
|
|
cols = {c.name for c in Tag.__table__.columns}
|
|
assert "kind" in cols
|
|
assert "fandom_id" in cols
|
|
assert "namespace" not in cols
|
|
|
|
|
|
def test_tag_kind_enum_values():
|
|
# Current TagKind enum after alembic 0023 dropped meta + rating
|
|
# (operator-retired 2026-05-26). `artist` is still in the enum
|
|
# for backward-compat with historical rows, though new artist
|
|
# tags don't get created (Artist row is canonical per FC-2d-vii-c).
|
|
expected = {
|
|
"artist",
|
|
"character",
|
|
"fandom",
|
|
"general",
|
|
"series",
|
|
"archive",
|
|
"post",
|
|
}
|
|
assert {k.value for k in TagKind} == expected
|
|
|
|
|
|
def test_image_record_has_integrity_status():
|
|
from backend.app.models import ImageRecord
|
|
cols = {c.name for c in ImageRecord.__table__.columns}
|
|
assert "integrity_status" in cols
|
|
|
|
|
|
def test_import_task_has_state_columns():
|
|
cols = {c.name for c in ImportTask.__table__.columns}
|
|
for required in ("batch_id", "source_path", "task_type", "status", "result_image_id"):
|
|
assert required in cols
|
|
|
|
|
|
def test_import_settings_singleton_constraint():
|
|
constraints = {c.name for c in ImportSettings.__table__.constraints}
|
|
assert "ck_import_settings_singleton" in constraints
|