Usage tests: list helpers#216
Open
NandaScott wants to merge 1 commit into
Open
Conversation
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>
Contributor
There was a problem hiding this comment.
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, andmaponcards.Searchresult sets (including an empty-filter case). - Add a new captured fixture payload for a multi-set
cards/searchquery 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" | ||
| }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #210
Opened by Sandcastle. 1 commit(s) on
sandcastle/issue-210.