Skip to content

Commit db4abd5

Browse files
test: guard HTTP status constants
1 parent c469638 commit db4abd5

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import re
2+
from pathlib import Path
3+
4+
5+
API_ROOT = Path("quantara/web_app/api")
6+
LITERAL_STATUS_RE = re.compile(
7+
r"(status_code\s*=\s*(400|401|404|422)\b|HTTPException\(\s*(400|401|404|422)\s*,)"
8+
)
9+
10+
11+
def test_api_http_exceptions_use_status_constants():
12+
offenders: list[str] = []
13+
14+
for path in API_ROOT.rglob("*.py"):
15+
text = path.read_text(encoding="utf-8")
16+
if LITERAL_STATUS_RE.search(text):
17+
offenders.append(str(path))
18+
19+
assert offenders == []

0 commit comments

Comments
 (0)