mirror of
https://github.com/rennf93/roboco.git
synced 2026-08-03 07:23:24 +02:00
Converts 115 `# type: ignore[...]` suppressions across 23 test files to no-suppression patterns (helper-return widening to Any, local Any aliases, cc:Any aliases, cast at narrow call sites, typed fixtures) so the hard no-type:ignore convention holds across tests/. No test logic or assertions changed — only mock-wiring mechanics and type annotations. Gate: ruff check tests/ clean; mypy tests/ (538 files) clean; 176 changed-file tests pass. Zero real suppressions remain (the 7 grep hits are 3 hygiene- checker string-literal test inputs and 4 prose mentions in comments).
52 lines
1.8 KiB
Python
52 lines
1.8 KiB
Python
"""Wave A5 (2026-05-12): migration 013 drops the stray `role` postgres enum.
|
|
|
|
Smoke run 2 produced `UndefinedFunctionError: operator does not exist:
|
|
agentrole = role` because postgres had two enums for the same Python
|
|
class. The migration drops the unused one with a safety check.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import TYPE_CHECKING
|
|
|
|
import pytest
|
|
from sqlalchemy import text
|
|
|
|
if TYPE_CHECKING:
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_no_column_uses_role_type(db_session: AsyncSession) -> None:
|
|
"""Before dropping, confirm no column actually uses the `role` type.
|
|
|
|
If this ever fails it means a column was added that references the
|
|
`role` enum and the migration must NOT be allowed to drop it — that
|
|
column would become orphaned.
|
|
"""
|
|
result = await db_session.execute(
|
|
text(
|
|
"SELECT column_name, table_name "
|
|
"FROM information_schema.columns "
|
|
"WHERE udt_name = 'role'"
|
|
)
|
|
)
|
|
rows = list(result)
|
|
assert rows == [], (
|
|
f"columns still use `role` enum: {rows}; migration 013 cannot run"
|
|
)
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_role_enum_dropped_after_upgrade(db_session: AsyncSession) -> None:
|
|
"""After migration 013 runs, only `agentrole` remains; `role` is gone."""
|
|
# This test runs against a db where migrations have been applied to head.
|
|
# The conftest fixture should handle that — verify by reading the
|
|
# existing tests' conftest.
|
|
result = await db_session.execute(
|
|
text("SELECT typname FROM pg_type WHERE typname IN ('role', 'agentrole')")
|
|
)
|
|
rows = {row[0] for row in result}
|
|
assert "agentrole" in rows, "agentrole must remain (it's the live enum)"
|
|
assert "role" not in rows, "stray `role` enum should be dropped"
|