Add unit tests for hardware CLI commands#2486
Open
berendt wants to merge 1 commit into
Open
Conversation
Cover the hardware-related command modules with focused unit tests: - baremetal: provision-state decision matrix and config-drive assembly of BaremetalDeploy, playbook generation of BaremetalDump (Ironic and NetBox sources), undeploy state handling including SSH known_hosts cleanup, ping output parsing and device discovery, burn-in and clean step construction, the provide/maintenance/power wrappers, NetBox state clearing on delete, and the shared cloud-setup failure guard - server: live-migration flow including prompt handling and wait loop, the domain/project/user listing paths, age-based reporting of stuck servers, and ServerClean deletion behavior - redfish: new test module for the column mapping and filtering helpers and the table/JSON output paths of the list command - stress: new test module for command construction, flag propagation and error handling of the openstack-simple-stress wrapper Assisted-by: Claude:claude-fable-5 Signed-off-by: Christian Berendt <berendt@osism.tech>
berendt
force-pushed
the
unit-tests-hardware-commands
branch
from
July 18, 2026 11:57
3c17b73 to
d1df374
Compare
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.
Closes #2364
Adds unit tests for the hardware-related CLI command modules, following the mocking patterns established in #2193 (no Celery broker, no real cloud/NetBox access):
New test modules
tests/unit/commands/test_redfish.py: column name normalization, per-resource-type column mappings, column filtering (case-insensitive selection, unknown-column warning), JSON data filtering, table rendering, and alltake_actionoutput paths (JSON full/filtered/empty, table dispatch per resource type, unknown resource type, no result). Verifies the task lock is consulted before the Celery task is dispatched.tests/unit/commands/test_stress.py: default command construction of the openstack-simple-stress wrapper, boolean flag and custom value propagation, return code passthrough,FileNotFoundError/generic error handling, setup failure guard, and cleanup in all paths.Extended test modules
tests/unit/commands/test_baremetal.py:_apply_metalbox_vars, a parametrized cloud-setup failure guard over all commands of the module,BaremetalList(sorting,n/apower state, query flags, NetBox device-role column, cleanup on error),BaremetalDeploy(provision-state decision matrix,instance_inforefresh, validation failure, NetBoxlocal_context_dataincl.cf_inventory_hostnamefallback, netplan/FRR parameters, Supermicro boot device, RAID deploy steps, config-drive failure,--allloop resilience — playbook content is asserted by parsing the actualplaybook.ymlhanded toconfigdrive.pack),BaremetalDump(Ironic and NetBox sources),BaremetalUndeploy(state matrix, SSH known_hosts cleanup),BaremetalPing(_ping_hostoutput parsing incl. macOS/Linux variants, device discovery/filtering, summary),BaremetalBurnIn(clean/service step construction, manage flow, active-node confirmation),BaremetalClean(RAID step prepending, manage flow), the provide/maintenance/power wrappers, andBaremetalDelete(port-before-node ordering, NetBox state clearing on primary and secondary instances, failure resilience).tests/unit/commands/test_server.py:ServerMigrate(defaults,--target/--force, prompt handling, wait loop,--no-wait, PAUSED),ServerList(domain/project/user happy paths, domain-name fallback, age-based BUILD/ERROR reporting), andServerClean(build timeout handling, prompt handling, ERROR servers, cleanup infinally).No existing test cases were duplicated;
flake8andblackpass locally.🤖 Generated with Claude Code
https://claude.ai/code/session_01MRk7qVcmoKuk74USmgY8Mm