Make the Python client test suite runnable and document how to run it - #205
Merged
Merged
Conversation
…lect pytest.ini listed the package directories themselves, which supports preponderous.viron... imports, while the client and every test module import through src.main.python.preponderous.viron... and need the root instead. All eight test modules failed collection with ModuleNotFoundError: No module named 'src'. Point pythonpath at the root to match the import style already in use, and pin testpaths so a bare pytest run only picks up the client suite. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
environmentService was the only service using a PEP 585 builtin generic (list[Environment]); its siblings all use typing.List. Builtin generics in annotations are evaluated when the class body runs and are not subscriptable before Python 3.9, so importing EnvironmentService raised TypeError there and test_environmentService.py could not be collected. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The README mentioned the client directory but never said how to test it, and did not note that CI covers the Java build only. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
… pytest testpaths changed nothing measurable: a bare pytest run collects the same 107 tests without it, since no other test_*.py exists in the tree. The README now also records that pytest.ini's pythonpath setting arrived in pytest 7.0, so the 6.2.4 pinned by requirements.txt ignores it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Member
Author
|
Self-review rubric, scored against the diff at
Findings folded in from outside the rubric
One intrinsic-critique pass; no further self-scoring will follow absent a reviewer comment or a CI failure. This comment was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener). drafted by Claude on behalf of Daniel Stephenson |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
pytest.ini'spythonpathis pointed at the repository root. The previous value listed the package directories themselves, which supportspreponderous.viron...imports, whereas the client source and all eight test modules import throughsrc.main.python.preponderous.viron...— so every test module failed collection withModuleNotFoundError: No module named 'src'. Of the two ways out described in pytest fails to collect the Python client tests: pytest.ini's pythonpath does not match the tests' import style #201, the root was chosen deliberately: the alternative (rewriting the imports topreponderous.viron...) would have to change the client's own internal imports too, and that is the path external consumers import by, so it is an API decision rather than a test-configuration one.testpathsis also pinned so a barepytestrun picks up only the client suite.environmentService.get_all_environmentsis annotated withtyping.Listinstead of the builtin genericlist[Environment], matching all three sibling services. Builtin generics in annotations are evaluated when the class body runs and are not subscriptable before Python 3.9, soEnvironmentServicecould not be imported at all on 3.8 andtest_environmentService.pycould not be collected.src/test/python/.Test plan
mvn -B test— 424 tests, 0 failures, 0 errors, BUILD SUCCESSpytest(pytest 9.0.3) — 107 passedpython3 -m pytest(Python 3.8.10, pytest 7.1.3) — 107 passed, confirming the annotation fix on the lowest interpreter available herepytest.inistashed,pytestreportsInterrupted: 8 errors during collection; restored, 107 passenvironmentService.pystashed,python3 -m pytestreportsTypeError: 'type' object is not subscriptablecollectingtest_environmentService.py; restored, 107 pass. Note this failure is only observable on Python 3.8 — on 3.9+ the reverted annotation is valid, so the suite alone does not guard it.Notes on the rest of the backlog
Deferred this cycle, with reasons recorded here per the loop's auditability rule:
moveEntityToLocation's read-then-write race) — the issue's own acceptance criteria are gated on a design decision that is not the loop's to make: whether one-entity-per-location is meant to be a real invariant of the data or a rule of that one endpoint.addEntityToLocationcurrently ignores occupancy entirely, so either answer implies changes beyond the reported endpoint. A conditional-write fix (option 3) is implementable without settling that question and is the recommended next step once the question is answered.pom.xmland.github/workflows/, both on the do-not-auto-merge list, and larger than a polish-sized PR.CI runs
./mvnw compileand./mvnw testonly, so a green run does not exercise any file changed here except by proving the Java build is unaffected; the Python verification above was performed locally.Closes #201
Closes #204
This PR description was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).
drafted by Claude on behalf of Daniel Stephenson