Skip to content

test: lock that the deck list omits cards#33

Merged
lesnik512 merged 1 commit into
mainfrom
test/lock-deck-list-contract
Jun 26, 2026
Merged

test: lock that the deck list omits cards#33
lesnik512 merged 1 commit into
mainfrom
test/lock-deck-list-contract

Conversation

@lesnik512

Copy link
Copy Markdown
Member

Why

PR #30 split the Deck response contract — light Deck for list/create/update, DeckWithCards for get_deck — but no test asserted that cards is absent from list responses. The existing tests passed under both the old and new schema, so the contract wasn't pinned.

What

test_list_decks_omits_cards creates a deck with a card, then asserts the list item has no cards key:

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/")
    item = response.json()["items"][0]
    assert "cards" not in item

Under the old single-schema design this would have failedlist_decks returned the misleading cards: [] even for decks with cards (the noload lie #30 removed). So the test locks the fix and would catch a regression that re-added cards to the light contract. test_get_one_deck already locks the other half (detail includes cards).

21 passed, 100% coverage.

🤖 Generated with Claude Code

PR #30 split the Deck response contract (light Deck for lists,
DeckWithCards for detail) but no test asserted that cards is absent
from list responses — the existing tests passed either way.

Add a test that creates a deck WITH a card and asserts the list item
has no cards key. Under the old single-schema design this would have
failed (it returned the misleading cards: []), so it pins the fix.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@lesnik512 lesnik512 merged commit c991b8a into main Jun 26, 2026
2 checks passed
@lesnik512 lesnik512 deleted the test/lock-deck-list-contract branch June 26, 2026 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant