refactor: update module docstrings for clarity and consistency

This commit is contained in:
Abhimanyu Saharan
2026-02-09 15:49:50 +05:30
parent 78bb08d4a3
commit 7ca1899d9f
99 changed files with 2345 additions and 855 deletions

View File

@@ -1,7 +1,10 @@
# ruff: noqa: INP001, S101
"""Regression tests for board deletion cleanup behavior."""
from __future__ import annotations
from dataclasses import dataclass, field
from typing import Any
from typing import TYPE_CHECKING, cast
from uuid import uuid4
import pytest
@@ -9,27 +12,32 @@ import pytest
from app.api import boards
from app.models.boards import Board
if TYPE_CHECKING:
from sqlmodel.ext.asyncio.session import AsyncSession
_NO_EXEC_RESULTS_ERROR = "No more exec_results left for session.exec"
@dataclass
class _FakeSession:
exec_results: list[Any]
executed: list[Any] = field(default_factory=list)
deleted: list[Any] = field(default_factory=list)
exec_results: list[object]
executed: list[object] = field(default_factory=list)
deleted: list[object] = field(default_factory=list)
committed: int = 0
async def exec(self, statement: Any) -> Any:
async def exec(self, statement: object) -> object | None:
is_dml = statement.__class__.__name__ in {"Delete", "Update", "Insert"}
if is_dml:
self.executed.append(statement)
return None
if not self.exec_results:
raise AssertionError("No more exec_results left for session.exec")
raise AssertionError(_NO_EXEC_RESULTS_ERROR)
return self.exec_results.pop(0)
async def execute(self, statement: Any) -> None:
async def execute(self, statement: object) -> None:
self.executed.append(statement)
async def delete(self, value: Any) -> None:
async def delete(self, value: object) -> None:
self.deleted.append(value)
async def commit(self) -> None:
@@ -38,6 +46,7 @@ class _FakeSession:
@pytest.mark.asyncio
async def test_delete_board_cleans_org_board_access_rows() -> None:
"""Deleting a board should clear org-board access rows before commit."""
session = _FakeSession(exec_results=[[], []])
board = Board(
id=uuid4(),
@@ -47,7 +56,10 @@ async def test_delete_board_cleans_org_board_access_rows() -> None:
gateway_id=None,
)
await boards.delete_board(session=session, board=board)
await boards.delete_board(
session=cast("AsyncSession", session),
board=board,
)
deleted_table_names = [statement.table.name for statement in session.executed]
assert "organization_board_access" in deleted_table_names