tests: raise sdk-python coverage from 73% to 100%#1
Merged
Conversation
Adds four new test files covering the modules and branches the existing suite skipped: - tests/test_cli.py: every console-script entry point (run_pilotctl, run_daemon, run_gateway, run_updater), with subprocess.call stubbed so no real binaries run. - tests/test_services.py: the high-level Driver helpers send_message, send_file, publish_event, subscribe_event. Verifies wire framing, hostname-resolution branches, ACK-read failure handling, and the three terminal cases of subscribe_event (clean EOF, error swallow, unhandled propagation). - tests/test_runtime_edges.py: 5-state seeder ETXTBSY skip path, atomic-install cleanup, _ensure_default_config race, _daemon_running socket-close swallow, and the runtime_binary / runtime_library wheel fallbacks. - tests/test_client_edges.py: _find_library ~/.pilot/bin branch, _void_ptr_to_bytes / _free helpers, Conn.read size <= 0 + 16MB cap, and the __version__ PackageNotFoundError fallback. All four production modules now report 100% line coverage. Test count goes from 124 to 204 passing (90 still skipped from the pre-existing fuzz suite). No production code was modified.
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. ℹ️ You can also turn on project coverage checks and project coverage reporting on Pull Request comment Thanks for integrating Codecov - We've got you covered ☂️ |
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
Adds four new test files that bring the four production modules in
pilotprotocol/from 73% → 100% line coverage. No production code was modified.pilotprotocol/__init__.pypilotprotocol/_runtime.pypilotprotocol/cli.pypilotprotocol/client.pyTest count: 124 → 204 passing (90 skipped fuzz tests unchanged).
New test files
tests/test_cli.py(8 tests) — every console-script entry point (run_pilotctl,run_daemon,run_gateway,run_updater) withsubprocess.callstubbed so no real binaries run. Verifies argv passthrough, non-zero exit propagation, and that the binary list matchespyproject.tomlconsole_scripts.tests/test_services.py(31 tests) — the high-levelDriverhelperssend_message(port 1001 data-exchange framing),send_file(TypeFile payload layout),publish_event(port 1002 subscribe-then-publish), andsubscribe_event(frame parsing + callback mode + every short-read termination + clean EOF + unhandled-error propagation). Uses aFakeConnthat records writes and serves canned reads — never touches libpilot or a daemon.tests/test_runtime_edges.py(32 tests) — the seeder edge cases the main test file skipped:ETXTBSYskip + reraise of other OSError, atomic-install cleanup onos.replacefailure,_ensure_default_configrace with another writer,_daemon_runningconfig + socket-close failure paths,_runtime_rootPILOT_HOME both branches,runtime_binary/runtime_librarywheel fallbacks,_semver_tupleparser edges,ensure_runtime_seededcache +force=Truebypass.tests/test_client_edges.py(9 tests) —_find_library~/.pilot/binbranch,_void_ptr_to_bytes+_freehelpers,Conn.readsize validation (<= 0returns empty without an FFI call,> 16MBcapped to 16MB), and the__version__PackageNotFoundErrorfallback to"unknown".Approach
All libpilot calls are mocked at the
ctypes.CDLLboundary via the sameFakeLibpattern the existingtest_client.pyuses. Service helpers are tested by replacingDriver.dialwith a fake that returns aFakeConn, so the wire-format assertions can run without a socket or shared library. The runtime seeder tests redirectPILOT_HOMEand_pkg_bin_dirinto a tmpdir so no~/.pilot/mutation happens on the host.Test plan
pytest --cov=pilotprotocol --cov-report=termreports 100% on all four modulesgit diff main -- pilotprotocol/is empty).github/workflows/ci.ymlalready runspytest --cov=pilotprotocolso this PR automatically uploads the new coverage to Codecov