Skip to content

chore(test): migrate unit tests to follow the new test layout#925

Draft
Bodong-Yang wants to merge 2 commits intomainfrom
worktree-chore+migrate_unit_tests
Draft

chore(test): migrate unit tests to follow the new test layout#925
Bodong-Yang wants to merge 2 commits intomainfrom
worktree-chore+migrate_unit_tests

Conversation

@Bodong-Yang
Copy link
Copy Markdown
Member

Introduction

Note

This PR is one of the PR from a PR set that does the full migration.

This PR migrates the tests that can be categorized into unit tests to the test/unit folder as follow:

Category Count Files
Pure renames (R100, content unchanged) 13 test_logging, test_typing, test_shm, test_retry_task_map, test_log_setting, test_cfg_configurable, test_cfg_consts, test_firmware_package, test_metadata_jwt, and the four proto_wrapper example files (example.proto, example_pb2.py, example_pb2.pyi, example_pb2_wrapper.py)
Renames with edits (mock re-point + mocker conversion, similarity 57–99%) 12 test_base (R057), test_metadata (R062), test_main (R068), test_download_bsp_version_file (R080), test_proto_wrapper (R082), test_nvidia_jetson_check_bsp (R085), test_ipc_interface (R092), test_utils (R094), test_jetson_common (R095), test_jetson_uefi (R095), test_status_monitor (R096), test_api_caller (R099), test_pb2_compat (R099)
New files 11 test/conftest.py, test/unit/test_otaclient/test_ota_core/conftest.py, test/unit/test_otaclient_api/test_v2/_compare.py, four extlinux fixtures under test/data/, rewritten unit tests test_detect_ota_image_spec.py, test_grpc/test_api_v2/test_main.py, test_otaclient_common/test_cmdhelper.py, plus required __init__.py files
Pure deletions (legacy file superseded by a rewrite above) 5 tests/test_otaclient_common/test_cmdhelper.py, tests/test_otaclient_api/test_v2/test_types.py, tests/test_ota_metadata/test_detect_ota_image_spec.py, tests/test_otaclient/test_grpc/test_api_v2/test_main.py, tests/test_otaclient_common/test_proto_wrapper/__init__.py

Move 26 unit-tier test files from tests/ to test/unit/, mirroring the
src/ package layout per MIGRATION_PLAN.md Phase 1. Mock targets re-
pointed at current src/ module paths (no legacy otaclient.app.*),
unittest.mock usages converted to pytest-mock's mocker, and duplicated
case bodies parametrized.

Conftest scoping per the plan: only the genuinely shared
ota_status_collector fixture lives at test/conftest.py;
mock_ensure_mount, mock_ensure_umount, mock_certs_dir, and the
fstrim_at_subprocess silencer are scoped to
test/unit/test_otaclient/test_ota_core/conftest.py since they only
matter inside the ota_core subsystem.

Also: extlinux text fixtures relocated to test/data/ (referenced via
Path(__file__).parents[3] / "data"); compare_message extracted to a
local _compare.py helper under test_otaclient_api/test_v2/ and inlined
in the proto_wrapper test to keep that subtree self-contained;
test_detect_ota_image_spec.py rewritten as a true unit test with a
mocked downloader (the legacy version implicitly relied on session-
autouse HTTP server fixtures).

All 679 unit tests pass under the docker-based suite (1 skipped).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Bodong-Yang Bodong-Yang self-assigned this Apr 27, 2026
@Bodong-Yang Bodong-Yang added test_files Add/change test files chore Pull requests that do not relate to a fix or feature and don't modify source code(like tagging, etc) labels Apr 27, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 27, 2026

📊 OTA Update Performance Comparison Report

Generated: 2026-04-27T02:53:50.700540

⏱️ Execution Time

Phase Legacy (s) V1 (s)
Total Duration 27.3 28.1
Metadata Processing 2.0 2.0
Delta Calculation 11.0 10.0
Download 2.0 4.0
Apply Update 6.0 6.0
Post Update 0.0 0.0
Finalization 0.0 0.0

@sonarqubecloud
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Pull requests that do not relate to a fix or feature and don't modify source code(like tagging, etc) test_files Add/change test files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant