test(wqp): parametrize the what_* tests + factor shared assertions#336
Merged
Merged
Conversation
…tions The eight `what_*` tests were near-identical — each issued the same `statecode`/`characteristicName` query against its own service endpoint and repeated the same six assertions, differing only by the service path segment, the response fixture, and the expected size. Collapse them into one `@pytest.mark.parametrize`d `test_what_query` (readable ids per wrapper), and factor the repeated metadata block (`url` / `query_time` / `mock_header` / `comment`) into a `_assert_wqp_metadata` helper now shared with the `get_results` tests too. Same coverage (all eight wrappers still exercised, each as its own parametrized case), ~75 fewer lines, and a new wrapper is now one row in `_WHAT_CASES`.
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.
What
The eight WQP
what_*tests (test_what_sites,test_what_organizations, …)were near-identical: each issued the same
statecode=US:34/characteristicName=Chloridequery against its own service endpoint andrepeated the same six assertions, differing only by:
Station,Organization,Activity, …),df.size.This collapses them into a single
@pytest.mark.parametrizedtest_what_querydriven by a
_WHAT_CASEStable, and factors the repeated metadata block(
md.url/query_time/mock_header/comment) into a_assert_wqp_metadatahelper now shared with theget_results/get_results_WQX3tests as well.Why it's safe
case with a readable id, so a failure still points at the exact wrapper:
DataFrame, size, andmetadata.
+59 / −149), and adding a newwhat_*wrapper is now one rowin
_WHAT_CASESinstead of a ~16-line copy-paste.Scope
WQP only — the clearest case from the suite review. A similar parametrize-refactor
of
nwis_test.py::TestMetaData(6 near-identicalsite_infocases) is a possiblefollow-up, but it lives in a file currently being changed by #335, so I left it
out to avoid churn.
🤖 Generated with Claude Code