Commit fa78869
committed
Polish PR 233: module-level constant, fix misleading comment, add 3 unit tests
Style alignment with the rest of `waterdata/utils.py`:
- Hoist `_cql2_required_services` from a function-local lowercase `set`
to a module-level `_CQL2_REQUIRED_SERVICES = frozenset(...)` to match
the convention of `_DATE_RANGE_PARAMS`, `_NO_NORMALIZE_PARAMS`,
`_MONITORING_LOCATION_ID_RE`, etc.
- Drop the "Legacy path:" prefix in the inline comment. POST/CQL2 is
still the current and required path for monitoring-locations — the
API team hasn't promised to add comma-GET there. Rephrased the two
branches symmetrically ("POST with CQL2 JSON" / "GET with comma-
separated values") so neither reads as deprecated.
New unit tests:
- `test_construct_api_requests_single_value_stays_get` — confirms a
scalar `monitoring_location_id="USGS-..."` still produces a clean GET
with no `%2C`, i.e. existing single-site callers see no change.
- `test_construct_api_requests_numeric_list_joins_with_str` — pins down
that `water_year=[2020, 2021]` reaches the URL as `water_year=2020%2C2021`,
exercising the `str(x) for x in v` generator that exists specifically
to handle non-string list params (without it, `",".join` on a list of
ints would TypeError).
- `test_construct_api_requests_two_element_date_list_becomes_interval` —
pins down the contract that a two-element date list (`time=["2024-01-01",
"2024-01-31"]`) is interpreted as start/end of an OGC datetime interval
(joined with `/`), NOT as two discrete dates. The OGC `datetime`
parameter doesn't support "these N specific dates" — that would
require a CQL filter. Test exists so this semantic choice can't be
silently changed.1 parent 7fe353b commit fa78869
2 files changed
Lines changed: 48 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
153 | 153 | | |
154 | 154 | | |
155 | 155 | | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
156 | 160 | | |
157 | 161 | | |
158 | 162 | | |
| |||
450 | 454 | | |
451 | 455 | | |
452 | 456 | | |
453 | | - | |
454 | | - | |
455 | | - | |
456 | | - | |
457 | 457 | | |
458 | 458 | | |
459 | 459 | | |
| |||
462 | 462 | | |
463 | 463 | | |
464 | 464 | | |
465 | | - | |
466 | | - | |
| 465 | + | |
| 466 | + | |
467 | 467 | | |
468 | 468 | | |
469 | 469 | | |
| |||
473 | 473 | | |
474 | 474 | | |
475 | 475 | | |
476 | | - | |
| 476 | + | |
477 | 477 | | |
478 | 478 | | |
479 | 479 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
134 | 134 | | |
135 | 135 | | |
136 | 136 | | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
137 | 178 | | |
138 | 179 | | |
139 | 180 | | |
| |||
0 commit comments