|
6 | 6 | Water Data API susceptible to flaking on a transient upstream blip |
7 | 7 | (e.g. the HTTP 502 Bad Gateway that broke CI on PR #273's merge). |
8 | 8 |
|
9 | | -Selection: a test is "live" iff (a) it does not request the |
10 | | -``requests_mock`` fixture, AND (b) its function body references one of |
11 | | -the package's public user-facing getters (the ``_PUBLIC_GETTERS`` set). |
12 | | -This skips pure unit tests of internal helpers (``_get_args``, |
13 | | -``_check_*``, ``_normalize_*``, ``_construct_api_requests``) that |
14 | | -share the test file with live tests. |
| 9 | +Scope: ``waterdata`` only. PR #273 specifically fixed the pagination |
| 10 | +loops in ``dataretrieval.waterdata.utils`` (``_walk_pages`` / |
| 11 | +``get_stats_data``); other modules (``wqp``, ``samples``, ``nadp``, |
| 12 | +``streamstats``, ``nldi``, ``nwis``) reach the network through |
| 13 | +different paths with their own error semantics and don't share PR |
| 14 | +#273's regression. |
| 15 | +
|
| 16 | +Selection: a test is "live" iff (a) its file path is under |
| 17 | +``tests/waterdata`` (other modules' tests are out of scope), AND (b) |
| 18 | +it does not request the ``requests_mock`` fixture, AND (c) its |
| 19 | +function body references one of the waterdata public user-facing |
| 20 | +getters (the ``_PUBLIC_GETTERS`` set). The file-path scope is |
| 21 | +necessary because some getter names (``get_ratings``, ``get_daily``) |
| 22 | +collide with legacy ``nwis`` function names; without the scope, a |
| 23 | +test of the legacy ``nwis.get_ratings`` would be retried under |
| 24 | +waterdata's transient-error patterns. The function-body check skips |
| 25 | +pure unit tests of internal helpers (``_get_args``, ``_check_*``, |
| 26 | +``_normalize_*``, ``_construct_api_requests``) that share the test |
| 27 | +file with live tests. |
15 | 28 |
|
16 | 29 | Retry: live tests are retried up to twice on a 5-second backoff, |
17 | 30 | but only when the failure trace matches a narrow transient-upstream |
|
24 | 37 |
|
25 | 38 | import pytest |
26 | 39 |
|
27 | | -# Public, network-doing entry points. The set is intentionally exhaustive |
28 | | -# so the source-inspection heuristic catches every test that exercises |
29 | | -# the library's user-facing API surface. Add new public getters here. |
| 40 | +# Public, network-doing entry points of the waterdata module. |
| 41 | +# Other modules' getters are intentionally out of scope (see module |
| 42 | +# docstring). Add new waterdata getters here. |
30 | 43 | _PUBLIC_GETTERS = frozenset( |
31 | 44 | { |
32 | | - # waterdata |
33 | 45 | "get_channel", |
34 | 46 | "get_combined_metadata", |
35 | 47 | "get_continuous", |
|
46 | 58 | "get_time_series_metadata", |
47 | 59 | "get_stats_por", |
48 | 60 | "get_stats_date_range", |
49 | | - # wqp / samples |
50 | | - "get_results", |
51 | | - "get_samples", |
52 | | - "get_samples_summary", |
53 | | - "what_activities", |
54 | | - "what_activity_metrics", |
55 | | - "what_detection_limits", |
56 | | - "what_habitat_metrics", |
57 | | - "what_organizations", |
58 | | - "what_project_weights", |
59 | | - "what_projects", |
60 | | - "what_sites", |
61 | | - # nadp |
62 | | - "get_annual_MDN_map", |
63 | | - "get_annual_NTN_map", |
64 | | - "get_zip", |
65 | | - # streamstats / nldi |
66 | | - "get_basin", |
67 | | - "get_features", |
68 | | - "get_features_by_data_source", |
69 | | - "get_flowlines", |
70 | | - "get_sample_watershed", |
71 | | - "get_watershed", |
72 | | - # nwis (legacy) |
73 | | - "get_discharge_measurements", |
74 | | - "get_discharge_peaks", |
75 | | - "get_dv", |
76 | | - "get_gwlevels", |
77 | | - "get_info", |
78 | | - "get_iv", |
79 | | - "get_pmcodes", |
80 | | - "get_qwdata", |
81 | | - "get_record", |
82 | | - "get_stats", |
83 | | - "get_water_use", |
84 | 61 | } |
85 | 62 | ) |
86 | 63 |
|
|
102 | 79 |
|
103 | 80 | def pytest_collection_modifyitems(config, items): |
104 | 81 | for item in items: |
| 82 | + # Scope: waterdata test files only. See module docstring for why |
| 83 | + # this file-path filter is needed in addition to the name check. |
| 84 | + if "tests/waterdata" not in item.nodeid.replace("\\", "/"): |
| 85 | + continue |
105 | 86 | if "requests_mock" in item.fixturenames: |
106 | 87 | continue |
107 | 88 | try: |
|
0 commit comments