refactor: update module docstrings for clarity and consistency
This commit is contained in:
@@ -1,24 +1,30 @@
|
||||
# ruff: noqa: INP001, S101
|
||||
"""Regression test for board-group delete ordering."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass, field
|
||||
from types import SimpleNamespace
|
||||
from typing import Any
|
||||
from typing import TYPE_CHECKING, cast
|
||||
from uuid import uuid4
|
||||
|
||||
import pytest
|
||||
|
||||
from app.api import board_groups
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sqlmodel.ext.asyncio.session import AsyncSession
|
||||
|
||||
|
||||
@dataclass
|
||||
class _FakeSession:
|
||||
executed: list[Any] = field(default_factory=list)
|
||||
executed: list[object] = field(default_factory=list)
|
||||
committed: int = 0
|
||||
|
||||
async def exec(self, statement: Any) -> None:
|
||||
async def exec(self, statement: object) -> None:
|
||||
self.executed.append(statement)
|
||||
|
||||
async def execute(self, statement: Any) -> None:
|
||||
async def execute(self, statement: object) -> None:
|
||||
self.executed.append(statement)
|
||||
|
||||
async def commit(self) -> None:
|
||||
@@ -29,17 +35,26 @@ class _FakeSession:
|
||||
async def test_delete_board_group_cleans_group_memory_first(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
"""Delete should remove boards, memory, then the board-group record."""
|
||||
group_id = uuid4()
|
||||
|
||||
async def _fake_require_group_access(*_args: Any, **_kwargs: Any) -> None:
|
||||
async def _fake_require_group_access(*_args: object, **_kwargs: object) -> None:
|
||||
return None
|
||||
|
||||
monkeypatch.setattr(board_groups, "_require_group_access", _fake_require_group_access)
|
||||
monkeypatch.setattr(
|
||||
board_groups,
|
||||
"_require_group_access",
|
||||
_fake_require_group_access,
|
||||
)
|
||||
|
||||
session = _FakeSession()
|
||||
ctx = SimpleNamespace(member=object())
|
||||
|
||||
await board_groups.delete_board_group(group_id=group_id, session=session, ctx=ctx)
|
||||
await board_groups.delete_board_group(
|
||||
group_id=group_id,
|
||||
session=cast("AsyncSession", session),
|
||||
ctx=ctx,
|
||||
)
|
||||
|
||||
statement_tables = [statement.table.name for statement in session.executed]
|
||||
assert statement_tables == ["boards", "board_group_memory", "board_groups"]
|
||||
|
||||
Reference in New Issue
Block a user