Skip to content

test: pin the Python grid client's failure paths - #267

Merged
dmccoystephenson merged 1 commit into
mainfrom
feature/grid-client-failure-paths
Nov 11, 2026
Merged

dmccoystephenson merged 1 commit into
mainfrom
feature/grid-client-failure-paths

Conversation

@dmccoystephenson

Copy link
Copy Markdown
Member

Summary

This is a Stage B (unit-test expansion) cycle. It covers the Python client's GridService (src/main/python/preponderous/viron/services/gridService.py) and follows on from the entity client in #266. Before this PR, the grid client's failure tests asserted only that some Exception escapes. Two of them also contained an assert grid is None inside the pytest.raises block, which never runs. This PR adds eleven characterization tests to src/test/python/preponderous/viron/services/test_gridService.py and changes no production code.

What is now pinned:

  • Errors propagate unwrapped from every method. A 503 on get_all_grids and a 404 on get_grid_by_id, get_grids_in_environment and get_grid_of_entity all raise the HTTPError from raise_for_status(). In each case .json() is never read.
  • update_grid_name does not wrap its errors. A 404, a 400 and a ConnectionError reach the caller as their original types (exc_info.type is HTTPError). This is the opposite of EntityService.update_entity_name, which re-raises a bare Exception (pinned in test: pin the Python entity client's failure paths #266).
  • update_grid_name returns status_code == 200. A 2xx other than 200 (here 204) returns False without raising. GridController.updateGridName is a void handler, so the server answers 200 today.
  • The bearer token reaches the write. Before this PR, only get_all_grids was checked for it.
  • A null body is not guarded. get_grid_by_id and get_all_grids raise TypeError on a null body.

Observation (not changed here)

get_grid_by_id and get_grid_of_entity are annotated Optional[Grid], but neither ever returns None. A 404 raises, and a null body raises TypeError. The environment and location clients behave the same way and annotate without Optional. EntityService is the only client that maps a null body to None or []. The server answers a missing grid with a 404 rather than a null 200, so this has no practical effect today. It is recorded here instead of being filed as a defect.

Deferred issues

Test plan

  • pytest -q (pytest 9.0.3): 147 passed (136 before, 11 new)
  • python3 -m pytest -q (pytest 7.1.3, Python 3.8): 147 passed
  • CI green on the PR head. The CI workflow's Python jobs run this suite. No Java file is touched.

No tracking issue. The gap was found during triage.

This PR description was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).

🤖 Generated with Claude Code


drafted by Claude on behalf of Daniel Stephenson

The grid client's tests asserted only that some Exception escapes a
failing call. Every GridService method lets the HTTPError from
raise_for_status, or the requests error itself, propagate unwrapped,
including update_grid_name, which differs from the entity client's
wrapped writes. That is now asserted, along with the JSON body never
being read on an error, a non-200 2xx rename returning False, the bearer
token reaching the write, and the TypeError a null body produces where
the entity client falls back to None or [].

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dmccoystephenson

Copy link
Copy Markdown
Member Author

Self-review rubric, scored against the diff and CI run 42977141134:

  • Scope: PASS. One file changed (src/test/python/preponderous/viron/services/test_gridService.py), and the change only adds lines. No production code, formatting or rename churn.
  • Tests-new: PASS (N/A). No new public method is added. All five GridService methods now have an error-path assertion that names the error type.
  • Tests-fix: N/A. This is a characterization cycle with no fix, so there is nothing to revert. The new tests pass against the current source on both runtimes (147 passed under pytest 9.0.3 and under pytest 7.1.3 / Python 3.8).
  • Sibling structure: PASS. The new tests follow the file's existing class-per-concern layout (TestFailurePaths) and reuse the _error_response helper shape from test_entityService.py.
  • Sibling renames: N/A. Nothing is renamed.
  • Docs: PASS. No behaviour changes, so none of the Phase 7 sources (OpenAPI spec, MVP/PLANNING/REBUILD_PLAN, tickets.md, README, Postman) is affected.
  • Issue resolution: N/A. The PR closes no issue, and the body says the gap was found during triage.
  • CI: PASS. build, python-client (3.8) and python-client (3.12) are green on the head. The Python jobs execute this suite.
  • DTO boundary / Spec alignment / Override correctness: N/A. No Java is touched.
  • Java/Python parallelism: PASS (N/A). Behaviour is unchanged on both sides.

Judgment call flagged rather than acted on: test_update_grid_name_other_success_status_returns_false pins a False return for a 204. The server never sends a 204 for this route today (GridController.updateGridName is void, so it answers 200). The test is therefore a guard on the client's status_code == 200 comparison, not on a real server response. The two pre-existing test_not_found methods still contain an unreachable assert grid is None inside pytest.raises. They were left untouched to keep this change additive. The new tests cover the same paths with a typed assertion.

This comment was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).


drafted by Claude on behalf of Daniel Stephenson

@dmccoystephenson
dmccoystephenson merged commit a3fc1db into main Nov 11, 2026
3 checks passed
@dmccoystephenson
dmccoystephenson deleted the feature/grid-client-failure-paths branch November 11, 2026 07:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant