Skip to content

Add HTTP record/replay cassette for offline API tests#283

Merged
JE-Chen merged 1 commit into
devfrom
feat/http-cassette-batch
Jun 21, 2026
Merged

Add HTTP record/replay cassette for offline API tests#283
JE-Chen merged 1 commit into
devfrom
feat/http-cassette-batch

Conversation

@JE-Chen

@JE-Chen JE-Chen commented Jun 21, 2026

Copy link
Copy Markdown
Member

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 urllib transport. This:

  • Refactors the client (non-breaking) to expose a build_call / urllib_transport seam — http_request keeps its exact surface.
  • Adds Cassette / CassetteMissError (utils/http_cassette/): replay returns a recorded response for a matching request (pure, no network — the CI-valuable half), recording_transport is a thin pass-through over a live transport. Match on method/url (optionally body); save/load JSON cassettes.

Layers

  • Headless core: utils/http_cassette/http_cassette.py (pure stdlib json, zero PySide6).
  • Facade: Cassette, CassetteMissError exported from je_auto_control + __all__.
  • Executor: AC_http_replay.
  • MCP: ac_http_replay (read-only).
  • Script Builder: AC_http_replay under Data.
  • Tests: test/unit_test/headless/test_http_cassette_batch.py (9 tests, no Qt/network).
  • Docs: 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.
  • Package stays Qt-free (import je_auto_control imports no PySide6).

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.
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 42 complexity · 2 duplication

Metric Results
Complexity 42
Duplication 2

View in Codacy

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.

@JE-Chen JE-Chen merged commit 0cdca27 into dev Jun 21, 2026
16 checks passed
@JE-Chen JE-Chen deleted the feat/http-cassette-batch branch June 21, 2026 13:29
@sonarqubecloud

Copy link
Copy Markdown

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