Skip to content

Usage tests: list helpers#216

Open
NandaScott wants to merge 1 commit into
prd/behavior-and-convenience-usage-testsfrom
sandcastle/issue-210
Open

Usage tests: list helpers#216
NandaScott wants to merge 1 commit into
prd/behavior-and-convenience-usage-testsfrom
sandcastle/issue-210

Conversation

@NandaScott
Copy link
Copy Markdown
Owner

Closes #210

Opened by Sandcastle. 1 commit(s) on sandcastle/issue-210.

Covers all acceptance criteria from issue #210:
- as_dict keyed by name and by card_id
- filter by set with non-empty and empty-result cases
- map to names and to (name, set) tuples
- chaining: filter result piped through map

Adds the cards_search__multiset fixture (4 cards across LEA and M10)
to exercise set-based filtering in a stubbed Search response.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new tests/usage/ module and fixture to exercise the public list-helper methods on scrython.cards.Search results (as requested in issue #210), wiring the captured search payload into the usage-test harness.

Changes:

  • Add usage tests covering as_dict, filter, and map on cards.Search result sets (including an empty-filter case).
  • Add a new captured fixture payload for a multi-set cards/search query and register it in the usage-suite fixture injection map.
  • Add fixture-capture spec for the new usage fixture in scripts/capture_fixtures.py.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 15 comments.

File Description
tests/usage/test_list_helpers.py New usage tests for list helper methods on scrython.cards.Search.
tests/usage/fixtures/cards_search__multiset.json New committed fixture payload backing the cards/search usage tests.
tests/usage/conftest.py Registers cards_search__multiset as an injected payload fixture for the usage harness.
scripts/capture_fixtures.py Adds capture spec for the new cards_search__multiset fixture (query + ordering).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +13 to +15
def test_search__as_dict__keyed_by_name_is_addressable(cards_search__multiset):
results = scrython.cards.Search(q=_QUERY)
by_name = results.as_dict("name")
Comment on lines +20 to +22
def test_search__as_dict__keyed_by_id_round_trips(cards_search__multiset):
results = scrython.cards.Search(q=_QUERY)
by_id = results.as_dict("card_id")
Comment on lines +28 to +30
def test_search__filter__by_set_returns_only_matching_cards(cards_search__multiset):
results = scrython.cards.Search(q=_QUERY)
lea_cards = results.filter(lambda card: card.set == "lea")
Comment on lines +35 to +37
def test_search__filter__empty_result_returns_empty_list(cards_search__multiset):
results = scrython.cards.Search(q=_QUERY)
no_cards = results.filter(lambda card: card.set == "thb")
Comment on lines +41 to +43
def test_search__map__to_names(cards_search__multiset):
results = scrython.cards.Search(q=_QUERY)
names = results.map(lambda card: card.name)
Comment on lines +35 to +37
def test_search__filter__empty_result_returns_empty_list(cards_search__multiset):
results = scrython.cards.Search(q=_QUERY)
no_cards = results.filter(lambda card: card.set == "thb")
Comment on lines +41 to +43
def test_search__map__to_names(cards_search__multiset):
results = scrython.cards.Search(q=_QUERY)
names = results.map(lambda card: card.name)
Comment on lines +49 to +51
def test_search__map__to_name_set_tuples(cards_search__multiset):
results = scrython.cards.Search(q=_QUERY)
tuples = results.map(lambda card: (card.name, card.set))
Comment on lines +56 to +58
def test_search__chain__filter_by_set_then_map_to_names(cards_search__multiset):
results = scrython.cards.Search(q=_QUERY)
lea_names = list(map(lambda card: card.name, results.filter(lambda card: card.set == "lea")))
Comment on lines +1 to +6
{
"_provenance": {
"captured_at": "2026-06-01T00:00:00.000000+00:00",
"endpoint": "cards/search",
"source_url": "https://api.scryfall.com/cards/search?q=%28name%3A%22Counterspell%22+or+name%3A%22Lightning+Bolt%22%29+s%3Alea+or+%28name%3A%22Fireball%22+or+name%3A%22Giant+Growth%22%29+s%3Am10&order=name&unique=prints"
},
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.

2 participants