test(ble): add mocked transport coverage for BLE commands - #47
Merged
Conversation
added 2 commits
July 9, 2026 18:05
VehicleBluetooth inherits its entire signed-command surface from Commands but had zero BLE-specific command tests. tests/ble_mocked_transport.py patches _send with canned RoutableMessage replies (no real BLE/GATT connection) so command-to-proto construction and reply decoding are unit-testable; every later BLE command-test PR builds on this base.
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.
Intent
Add foundational BLE test scaffolding (PR-0 of the BLE production-readiness master plan): a reusable in-repo mocked-transport unit-test base (tests/ble_mocked_transport.py + tests/test_ble_mocked_commands.py) that patches VehicleBluetooth._send with canned RoutableMessage replies so inherited Commands (door_lock/VCSEC, set_temps/INFO action, charge_state/INFO typed read) can be driven and their signed RoutableMessage + decoded reply asserted with NO real BLE/GATT connection ever opened. This is infrastructure only - no new BLE actuation behavior, no live car interaction. The master plan (report.md) established that VehicleBluetooth already inherits the entire ~110-command signed-command surface from Commands, so this program is verify+test scaffolding, not re-implementation; PR-0 is explicitly the safe-to-self-merge first step every later BLE command-test PR builds on. A second deliverable (extending the local dev-only BLE harness with a generic snapshot->act->verify->restore 'cmd' subcommand) was done in scripts/ble-harness/, which is deliberately git-excluded via .git/info/exclude and does not appear in this diff - it was verified with --help only, never run against a real car, and was re-persisted to the external harness snapshot location outside this repo. AGENTS.md was updated with a short pointer to the new test base for future BLE test-writing sessions.
What Changed
VehicleBluetooth._send, supplies canned signed-command replies, and exposes helpers for decrypting/asserting generatedRoutableMessagepayloads without opening a real BLE/GATT connection.Commandsmethods.AGENTS.mdfor future BLE command tests.Risk Assessment
✅ Low: The branch is narrowly scoped to BLE test scaffolding and documentation, with no production behavior changes and no material correctness risks found in the reviewed diff.
Testing
Inspected the BLE test-scaffold diff, ran the focused mocked BLE command tests and the full test suite successfully, then produced JSON evidence showing decoded signed command payloads and canned replies for VCSEC, infotainment action, and typed read paths with real BLE connection attempts guarded and unused.
Evidence: Mocked BLE transport behavior evidence
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
✅ **Test** - passed
✅ No issues found.
git diff --stat c16d2540ec1a67fe24d152fac7597bb2379e8464..HEADand related file inspection oftests/ble_mocked_transport.py,tests/test_ble_mocked_commands.py, andAGENTS.mduv run pytest tests/test_ble_mocked_commands.py -vvuv run pytest testsGenerated/tmp/no-mistakes-evidence/01KX2YR32ZVB7W6R2F6W2HHGQQ/ble_mocked_transport_evidence.jsonby drivingdoor_lock,set_temps(21.5, 19.0), andcharge_statethroughMockedBleTransportTestCase, decrypting sentRoutableMessagepayloads, and patchingestablish_connectionto raise if real BLE connect was attempted✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.