test: whole-table tag counts become non-system counts
CI / lint (push) Successful in 2s
CI / frontend-build (push) Successful in 18s
CI / backend-lint-and-test (push) Successful in 33s
CI / integration (push) Successful in 3m32s

The four remaining run-1895 failures were stale expectations, not
predicate bugs — prune/reset returned the right counts, but these tests
verified no-deletion by counting the ENTIRE tag table (or asserting the
full kind set), which now includes the three seeded hygiene tags that
survive prunes and resets by design. Filter is_system=false with a
pointer to #128 so future system tags cannot re-break them.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CDgx8bQS5YrGRK76v8HUnM
This commit is contained in:
2026-07-03 08:40:11 -04:00
parent f77e75147d
commit 65bd1c22c3
2 changed files with 18 additions and 7 deletions
+3 -1
View File
@@ -660,8 +660,10 @@ async def test_reset_content_tagging_apply_requires_confirm_token(client, db):
for bad in ({"dry_run": False}, {"dry_run": False, "confirm": "deadbeef"}): for bad in ({"dry_run": False}, {"dry_run": False, "confirm": "deadbeef"}):
resp = await client.post("/api/admin/tags/reset-content", json=bad) resp = await client.post("/api/admin/tags/reset-content", json=bad)
assert resp.status_code == 400 assert resp.status_code == 400
# Non-system only: the seeded hygiene tags (#128) survive a reset by
# design, so they'd inflate a whole-table count.
remaining = (await db.execute( remaining = (await db.execute(
select(func.count()).select_from(Tag) select(func.count()).select_from(Tag).where(Tag.is_system.is_(False))
)).scalar_one() )).scalar_one()
assert remaining == 1 assert remaining == 1
+15 -6
View File
@@ -377,8 +377,11 @@ def test_prune_unused_tags_dry_run_returns_count_and_names(db_sync, tmp_path):
assert result["count"] == 2 assert result["count"] == 2
assert "prune-me-1" in result["sample_names"] assert "prune-me-1" in result["sample_names"]
assert "prune-me-2" in result["sample_names"] assert "prune-me-2" in result["sample_names"]
# Nothing actually deleted. # Nothing actually deleted. Non-system only — the seeded hygiene tags
surviving = db_sync.execute(select(func.count(Tag.id))).scalar_one() # (#128) are exempt from pruning and would inflate a whole-table count.
surviving = db_sync.execute(
select(func.count(Tag.id)).where(Tag.is_system.is_(False))
).scalar_one()
assert surviving == 3 assert surviving == 3
@@ -499,8 +502,11 @@ def test_reset_content_tagging_dry_run_counts_without_deleting(db_sync, tmp_path
assert result["count"] == 2 assert result["count"] == 2
assert result["by_kind"] == {"general": 1, "character": 1} assert result["by_kind"] == {"general": 1, "character": 1}
assert result["applications"] == 2 assert result["applications"] == 2
# Nothing deleted — all 4 tags still present. # Nothing deleted — all 4 fixture tags still present (non-system count;
assert db_sync.execute(select(func.count(Tag.id))).scalar_one() == 4 # the seeded hygiene tags #128 also survive, by design).
assert db_sync.execute(
select(func.count(Tag.id)).where(Tag.is_system.is_(False))
).scalar_one() == 4
def test_reset_content_tagging_deletes_content_keeps_fandom_series(db_sync, tmp_path): def test_reset_content_tagging_deletes_content_keeps_fandom_series(db_sync, tmp_path):
@@ -525,8 +531,11 @@ def test_reset_content_tagging_deletes_content_keeps_fandom_series(db_sync, tmp_
result = cleanup_service.reset_content_tagging(db_sync, dry_run=False) result = cleanup_service.reset_content_tagging(db_sync, dry_run=False)
assert result["deleted"] == 2 assert result["deleted"] == 2
# general + character gone; fandom + series kept. # general + character gone; fandom + series kept. Non-system only — the
kinds = db_sync.execute(select(Tag.kind)).scalars().all() # seeded hygiene tags (#128, kind=general) survive a reset by design.
kinds = db_sync.execute(
select(Tag.kind).where(Tag.is_system.is_(False))
).scalars().all()
kind_vals = {k.value if hasattr(k, "value") else str(k) for k in kinds} kind_vals = {k.value if hasattr(k, "value") else str(k) for k in kinds}
assert kind_vals == {"fandom", "series"} assert kind_vals == {"fandom", "series"}
# series_page ordering survived. # series_page ordering survived.