Skip to content

Commit

Permalink
BSENG-2235 reformat code
Browse files Browse the repository at this point in the history
  • Loading branch information
zxhdaze committed Apr 3, 2024
1 parent 8b91616 commit ce8ba5a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
6 changes: 3 additions & 3 deletions cou/steps/plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,17 +569,17 @@ async def _get_upgradable_hypervisors_machines(
machine_to_unit_name = {
machine.machine_id: unit.name
for unit, machine in zip(nova_compute_units, nova_compute_machines)
}
}
empty_hypervisor_ids = {machine.machine_id for machine in empty_hypervisors}
all_hypervisor_ids = {machine.machine_id for machine in nova_compute_machines}
skipped_hypervisor_ids = all_hypervisor_ids - empty_hypervisor_ids

skipped_unit_names = ', '.join(
skipped_unit_names = ", ".join(
machine_to_unit_name[machine_id] for machine_id in sorted(skipped_hypervisor_ids)
)
logger.info("Skipped (non-empty) hypervisors: %s", skipped_unit_names)

selected_unit_names = ', '.join(
selected_unit_names = ", ".join(
machine_to_unit_name[machine_id] for machine_id in sorted(empty_hypervisor_ids)
)
logger.info("Selected (empty) hypervisors: %s", selected_unit_names)
Expand Down
21 changes: 9 additions & 12 deletions tests/mocked_plans/test_base_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,14 @@ async def test_base_plan_non_empty(_, sample_plans, caplog):
analysis_results = await Analysis.create(model)
await generate_plan(analysis_results, args)

expected_skipped_log = (
"Skipped (non-empty) hypervisors: nova-compute/0, nova-compute/2"
)
expected_selected_log = (
"Selected (empty) hypervisors: nova-compute/1"
)
expected_skipped_log = "Skipped (non-empty) hypervisors: nova-compute/0, nova-compute/2"

assert any(
expected_skipped_log in message for message in caplog.messages
), f"Expected skipped log message not found: '{expected_skipped_log}'"
expected_selected_log = "Selected (empty) hypervisors: nova-compute/1"

assert any(
expected_selected_log in message for message in caplog.messages
), f"Expected selected log message not found: '{expected_selected_log}'"
assert any(expected_skipped_log in message for message in caplog.messages), (
"Expected skipped log message not found: '%s'" % expected_skipped_log
)

assert any(expected_selected_log in message for message in caplog.messages), (
"Expected selected log message not found: '%s'" % expected_selected_log
)

0 comments on commit ce8ba5a

Please sign in to comment.