Add HTTP record/replay cassette for offline API tests#283
Merged
Conversation
The HTTP client hardcoded its urllib transport, so a flow driving a real API could not be re-run in CI without the live server. Expose a build_call / urllib_transport seam on the client and layer a VCR-style cassette on top: replay returns a recorded response for a matching request (pure, no network), recording is a thin pass-through over a live transport. Wired through facade, executor (AC_http_replay), MCP, and the Script Builder with a headless test batch and EN/Zh docs.
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 42 |
| Duplication | 2 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
|
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.



What
Adds a VCR-style HTTP cassette so flows that drive a real API can be re-run in CI with no live server.
The HTTP client previously hardcoded its
urllibtransport. This:build_call/urllib_transportseam —http_requestkeeps its exact surface.Cassette/CassetteMissError(utils/http_cassette/):replayreturns a recorded response for a matching request (pure, no network — the CI-valuable half),recording_transportis a thin pass-through over a live transport. Match onmethod/url(optionallybody);save/loadJSON cassettes.Layers
utils/http_cassette/http_cassette.py(pure stdlibjson, zero PySide6).Cassette,CassetteMissErrorexported fromje_auto_control+__all__.AC_http_replay.ac_http_replay(read-only).AC_http_replayunder Data.test/unit_test/headless/test_http_cassette_batch.py(9 tests, no Qt/network).v75_features_doc.rst(EN + Zh) + toctrees + 3 README What's-new sections.Verification
pytest test/unit_test/headless/→ 2726 passed, 15 skipped.ruff check je_auto_control/clean; bandit clean; radon CC clean.import je_auto_controlimports no PySide6).