From c97ce30fb4d2bc21c19bde2acfd4bbdb62cdf754 Mon Sep 17 00:00:00 2001 From: Artur Shiriev Date: Fri, 26 Jun 2026 20:59:42 +0300 Subject: [PATCH] test: lock that the deck list omits cards MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Port the regression test from litestar-sqlalchemy-template#33. The Deck response contract is two-shaped: light `Deck` for list/create/update, `DeckWithCards` for get_deck. No test asserted that `cards` is absent from list responses, so the contract wasn't pinned — the existing tests passed under both the old single-schema design and the split. test_list_decks_omits_cards creates a deck with a card, then asserts the list item has no `cards` key. It would catch a regression that re-added `cards` to the light contract. test_get_one_deck already locks the other half (detail includes cards). Co-Authored-By: Claude Opus 4.8 (1M context) --- tests/test_decks.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/test_decks.py b/tests/test_decks.py index 478d26a..5686fa0 100644 --- a/tests/test_decks.py +++ b/tests/test_decks.py @@ -35,6 +35,16 @@ async def test_get_decks(client: AsyncClient) -> None: assert v == getattr(deck, k) +async def test_list_decks_omits_cards(client: AsyncClient) -> None: + deck = await factories.DeckModelFactory.create_async() + await factories.CardModelFactory.create_async(deck_id=deck.id) + + response = await client.get("/api/decks/") + assert response.status_code == status.HTTP_200_OK + item = response.json()["items"][0] + assert "cards" not in item + + async def test_get_one_deck(client: AsyncClient) -> None: deck = await factories.DeckModelFactory.create_async() card = await factories.CardModelFactory.create_async(deck_id=deck.id)