Skip to content

Commit f7ee659

Browse files
committed
test: cover fixed rate claim aliases
1 parent 96f1da1 commit f7ee659

3 files changed

Lines changed: 81 additions & 7 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
### Fixed
1313

14-
- Reject every fixed demo-rate literal, including the previously exempted
15-
daily allowance, and direct examples to the reviewed live product facts.
14+
- Reject common fixed request and API-call rate spellings, including prefix,
15+
suffix, and hyphenated daily/hourly/minute forms, and direct examples to the
16+
reviewed live product facts.
1617

1718
## [1.12.3] - 2026-08-11
1819

‎scripts/validate_storefront_claims.py‎

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,20 @@
2020
".pyo",
2121
".so",
2222
}
23+
_RATE_COUNT = r"\d[\d,]*"
24+
_RATE_ACTION = r"(?:(?:api[- ]+)?(?:requests?|calls?)|reqs?\.?)"
25+
_RATE_PERIOD = r"(?:minutes?|mins?\.?|hours?|hrs?\.?|days?)"
26+
_RATE_FREQUENCY = r"(?:minutely|hourly|daily|per[- ]+(?:minute|hour|day))"
27+
FIXED_RATE = re.compile(
28+
rf"\b{_RATE_COUNT}[- ]+{_RATE_ACTION}"
29+
rf"(?:(?:[- ]*(?:per|an?|each|every)[- ]+|[- ]*/[- ]*){_RATE_PERIOD}\b|"
30+
rf"[- ]+{_RATE_FREQUENCY}\b)|"
31+
rf"\b{_RATE_FREQUENCY}[- ]+"
32+
rf"(?:(?:api[- ]+)?(?:requests?|calls?)[- ]+)?"
33+
rf"(?:limit|allowance|quota|cap)\s*(?:of|is|:|=)?\s*"
34+
rf"{_RATE_COUNT}[- ]+{_RATE_ACTION}\b",
35+
re.IGNORECASE,
36+
)
2337
BLOCKED: Sequence[Tuple[str, Pattern[str]]] = (
2438
("real-time claim", re.compile(r"\breal[ -]?time\b", re.IGNORECASE)),
2539
(
@@ -87,11 +101,7 @@
87101
),
88102
(
89103
"fixed demo rate",
90-
re.compile(
91-
r"\b\d+\s+(?:requests?|reqs?\.?)\s*(?:(?:per|an?)\s+|/\s*)"
92-
r"(?:minutes?|mins?|hours?|hrs?|days?)\b",
93-
re.IGNORECASE,
94-
),
104+
FIXED_RATE,
95105
),
96106
)
97107

‎tests/test_storefront_claims.py‎

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
from pathlib import Path
2+
from typing import List
3+
4+
import pytest
25

36
from scripts.validate_storefront_claims import (
47
discover_installed_surfaces,
@@ -10,6 +13,28 @@
1013
ROOT = Path(__file__).resolve().parents[1]
1114

1215

16+
def _installed_text_failures(tmp_path: Path, text: str) -> List[str]:
17+
package = tmp_path / "oilpriceapi"
18+
dist_info = tmp_path / "oilpriceapi-9.9.9.dist-info"
19+
package.mkdir()
20+
dist_info.mkdir()
21+
(package / "version.py").write_text('__version__ = "9.9.9"\n')
22+
(package / "future.txt").write_text(text)
23+
(dist_info / "METADATA").write_text(
24+
"Metadata-Version: 2.1\n"
25+
"Name: oilpriceapi\n"
26+
"Version: 9.9.9\n\n"
27+
"https://api.oilpriceapi.com/product-facts.json\n"
28+
)
29+
(dist_info / "RECORD").write_text(
30+
"oilpriceapi/version.py,,\n"
31+
"oilpriceapi/future.txt,,\n"
32+
"oilpriceapi-9.9.9.dist-info/METADATA,,\n"
33+
"oilpriceapi-9.9.9.dist-info/RECORD,,\n"
34+
)
35+
return validate_package(tmp_path)
36+
37+
1338
def test_storefront_claims_match_reviewed_contract() -> None:
1439
assert validate() == []
1540

@@ -115,3 +140,41 @@ def test_rejects_claim_in_future_installed_package_data(tmp_path: Path) -> None:
115140
and "matched '50 requests/day'" in failure
116141
for failure in failures
117142
)
143+
144+
145+
@pytest.mark.parametrize(
146+
"claim",
147+
[
148+
"50 API calls/day",
149+
"50 calls per day",
150+
"50 requests daily",
151+
"daily limit of 50 requests",
152+
"50-request daily allowance",
153+
"100 API calls hourly",
154+
"hourly request quota: 100 calls",
155+
"3 reqs/minute",
156+
"50 calls each day",
157+
"100 API requests every hour",
158+
"daily cap is 50 calls",
159+
"50-call-per-day allowance",
160+
],
161+
)
162+
def test_rejects_fixed_rate_aliases_in_installed_text(tmp_path: Path, claim: str) -> None:
163+
failures = _installed_text_failures(tmp_path, claim)
164+
165+
assert any("fixed demo rate" in failure for failure in failures), failures
166+
167+
168+
@pytest.mark.parametrize(
169+
"text",
170+
[
171+
"SDK version 1.12.4 supports Python 3.8.",
172+
"Run 50 tests daily.",
173+
"The response contains 50 records per page.",
174+
"Retry attempt 50 failed.",
175+
],
176+
)
177+
def test_fixed_rate_aliases_do_not_match_versions_or_test_counts(
178+
tmp_path: Path, text: str
179+
) -> None:
180+
assert _installed_text_failures(tmp_path, text) == []

0 commit comments

Comments
 (0)