Skip to content

test: pin the Python entity client's failure paths - #266

Merged
dmccoystephenson merged 1 commit into
mainfrom
feature/entity-client-failure-tests
Nov 8, 2026
Merged

dmccoystephenson merged 1 commit into
mainfrom
feature/entity-client-failure-tests

Conversation

@dmccoystephenson

Copy link
Copy Markdown
Member

Summary

Stage B (unit-test expansion) cycle, aimed at the Python client's EntityService (src/main/python/preponderous/viron/services/entityService.py). Its tests covered the success path of every method but only one failure: a network error on get_all_entities. Eight characterization tests are added to src/test/python/preponderous/viron/services/test_entityService.py. No production code is changed.

The client's failure handling is not uniform, and the new tests record both shapes as they are today:

  • Reads and create_entity let the HTTPError from raise_for_status() propagate unchanged. They are now asserted for a 404 on get_entity_by_id and a 400 on create_entity, and in each case .json() is shown never to be read.
  • delete_entity and update_entity_name catch every exception and re-raise a bare Exception with a fixed message ("Error deleting entity", "Error updating entity name"). The original error is kept as args[1]. This is asserted for a 404, a 400 and a ConnectionError.
  • Empty-body fallbacks: get_entity_by_id returns None and the list reads return [] when the body is null.

Observation (not changed here)

Because delete_entity and update_entity_name wrap errors, a caller cannot except HTTPError on them the way it can on every other method in the client, or on EnvironmentService.delete_environment and GridService.update_grid_name. The original error is still reachable through args[1]. This could be by design, since it mirrors the Java client's EntityServiceException, so it is recorded here and not changed in a test-only cycle.

Deferred issues

Test plan

  • pytest -q (pytest 9.0.3): 136 passed (128 before, 8 new)
  • python3 -m pytest -q (pytest 7.1.3, Python 3.8): 136 passed
  • CI green on the PR head. The CI workflow's Python job runs this suite; the Java jobs are unaffected because 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 entity client's tests covered only the success path and one
network error on a read. Its failure handling is not uniform: the reads
and create_entity let raise_for_status's HTTPError propagate, while
delete_entity and update_entity_name catch it and re-raise a bare
Exception carrying a fixed message and the original error. Both shapes,
and the empty-body fallbacks to None and [], are now asserted as they
stand.

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

Copy link
Copy Markdown
Member Author

Self-review rubric (head feature/entity-client-failure-tests, one commit):

  • Scope: PASS. One file is changed (src/test/python/preponderous/viron/services/test_entityService.py, +94/-0). No production, doc or spec file is touched.
  • Tests-new: PASS. No public method is added. All eight new tests exercise existing EntityService methods on paths that had no coverage before.
  • Tests-fix: N/A. Nothing is fixed. These are characterization tests, so the stash-and-revert check does not apply.
  • Sibling structure: PASS. The new tests follow the file's existing style: module-level @patch('requests.<verb>') functions, the shared service instance, and a Mock() response. The one helper, _error_response, sits next to the tests that use it.
  • Sibling renames: N/A. Nothing is renamed.
  • Docs: PASS. Client behavior does not change, so no row of the documentation table is affected.
  • Issue resolution: N/A. No Closes #N. Skip reasons for One entity per location is enforced only by the move endpoint, so a concurrent placement still walks around it #213, The Python client cannot be installed or imported as a package; its modules import through the repository path #209 and Wire OpenAPI-first codegen / spec-drift guard (rebuild-plan hygiene gap) #130 are recorded in the PR body.
  • CI: PASS. build, python-client (3.8) and python-client (3.12) are all green on the head. The Python jobs run this file, so CI covers the change.
  • DTO boundary / Spec alignment / Override correctness: N/A. No Java code changed.
  • Java/Python parallelism: PASS, checked against the source. The PR body says the Python wrapping mirrors the Java client. src/main/java/preponderous/viron/services/EntityService.java:165 and :180 throw EntityServiceException with the same two messages the Python tests assert.

Judgment notes:

  • src/test/python/preponderous/viron/services/test_entityService.py:3: importing ConnectionError from requests.exceptions shadows the builtin inside this module. Nothing else in the file uses the builtin, so it is harmless. Left as it is.
  • The tests assert exc_info.type is Exception on purpose. A future change that makes delete_entity / update_entity_name re-raise HTTPError is a contract change for callers, and these tests are meant to flag it.

Merge-ready: CI is green, the change is test-only, and no do-not-auto-merge path is touched.

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


drafted by Claude on behalf of Daniel Stephenson

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