test: update test_get_nonexistent_play to expect 404 after HTTPException fix
All checks were successful
Build Docker Image / build (pull_request) Successful in 1m3s

After handle_db_errors no longer catches HTTPException, GET /plays/999999999
correctly returns 404 instead of 500. Update the assertion and docstring
to reflect the fixed behavior.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Cal Corum 2026-04-02 09:30:39 -05:00
parent 215085b326
commit c49f91cc19

View File

@ -81,9 +81,9 @@ class TestRouteRegistration:
for route, methods in EXPECTED_PLAY_ROUTES.items(): for route, methods in EXPECTED_PLAY_ROUTES.items():
assert route in paths, f"Route {route} missing from OpenAPI schema" assert route in paths, f"Route {route} missing from OpenAPI schema"
for method in methods: for method in methods:
assert ( assert method in paths[route], (
method in paths[route] f"Method {method.upper()} missing for {route}"
), f"Method {method.upper()} missing for {route}" )
def test_play_routes_have_plays_tag(self, api): def test_play_routes_have_plays_tag(self, api):
"""All play routes should be tagged with 'plays'.""" """All play routes should be tagged with 'plays'."""
@ -96,9 +96,9 @@ class TestRouteRegistration:
for method, spec in paths[route].items(): for method, spec in paths[route].items():
if method in ("get", "post", "patch", "delete"): if method in ("get", "post", "patch", "delete"):
tags = spec.get("tags", []) tags = spec.get("tags", [])
assert ( assert "plays" in tags, (
"plays" in tags f"{method.upper()} {route} missing 'plays' tag, has {tags}"
), f"{method.upper()} {route} missing 'plays' tag, has {tags}" )
@pytest.mark.post_deploy @pytest.mark.post_deploy
@pytest.mark.skip( @pytest.mark.skip(
@ -124,9 +124,9 @@ class TestRouteRegistration:
]: ]:
params = paths[route]["get"].get("parameters", []) params = paths[route]["get"].get("parameters", [])
param_names = [p["name"] for p in params] param_names = [p["name"] for p in params]
assert ( assert "sbaplayer_id" in param_names, (
"sbaplayer_id" in param_names f"sbaplayer_id parameter missing from {route}"
), f"sbaplayer_id parameter missing from {route}" )
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
@ -493,10 +493,9 @@ class TestPlayCrud:
assert result["id"] == play_id assert result["id"] == play_id
def test_get_nonexistent_play(self, api): def test_get_nonexistent_play(self, api):
"""GET /plays/999999999 returns an error (wrapped by handle_db_errors).""" """GET /plays/999999999 returns 404 Not Found."""
r = requests.get(f"{api}/api/v3/plays/999999999", timeout=10) r = requests.get(f"{api}/api/v3/plays/999999999", timeout=10)
# handle_db_errors wraps HTTPException as 500 with detail message assert r.status_code == 404
assert r.status_code == 500
assert "not found" in r.json().get("detail", "").lower() assert "not found" in r.json().get("detail", "").lower()
@ -575,9 +574,9 @@ class TestGroupBySbaPlayer:
) )
assert r_seasons.status_code == 200 assert r_seasons.status_code == 200
season_pas = [s["pa"] for s in r_seasons.json()["stats"]] season_pas = [s["pa"] for s in r_seasons.json()["stats"]]
assert career_pa >= max( assert career_pa >= max(season_pas), (
season_pas f"Career PA ({career_pa}) should be >= max season PA ({max(season_pas)})"
), f"Career PA ({career_pa}) should be >= max season PA ({max(season_pas)})" )
@pytest.mark.post_deploy @pytest.mark.post_deploy
def test_batting_sbaplayer_short_output(self, api): def test_batting_sbaplayer_short_output(self, api):