Skip to content

Commit 0c8ed8a

Browse files
author
Andrei Neagu
committed
refactor
1 parent 98ac056 commit 0c8ed8a

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

services/dynamic-sidecar/tests/unit/api/rest/test_containers_long_running_tasks.py

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -440,13 +440,13 @@ async def _assert_progress_finished(
440440
assert last_progress_message == ("finished", 1.0)
441441

442442

443-
async def _perioduc_result(
443+
async def _perioduc_result_and_task_removed(
444444
app: FastAPI,
445445
http_client: HttpClient,
446446
task_id: TaskId,
447447
*,
448448
progress_callback: ProgressCallback | None = None,
449-
) -> None:
449+
) -> Any | None:
450450
try:
451451
async with periodic_task_result(
452452
client=http_client,
@@ -481,7 +481,7 @@ async def create_progress(
481481
last_progress_message = (message, percent)
482482
print(message, percent)
483483

484-
result = await _perioduc_result(
484+
result = await _perioduc_result_and_task_removed(
485485
app,
486486
http_client,
487487
await _get_task_id_create_service_containers(
@@ -513,7 +513,7 @@ async def create_progress(
513513
last_progress_message = (message, percent)
514514
print(message, percent)
515515

516-
result = await _perioduc_result(
516+
result = await _perioduc_result_and_task_removed(
517517
app,
518518
http_client,
519519
await _get_task_id_create_service_containers(
@@ -524,7 +524,7 @@ async def create_progress(
524524
assert shared_store.container_names == result
525525
await _assert_progress_finished(last_progress_message)
526526

527-
result = await _perioduc_result(
527+
result = await _perioduc_result_and_task_removed(
528528
app,
529529
http_client,
530530
await _get_task_id_pull_user_servcices_docker_images(
@@ -544,7 +544,7 @@ async def test_create_containers_task_invalid_yaml_spec(
544544
mock_metrics_params: CreateServiceMetricsAdditionalParams,
545545
):
546546
with pytest.raises(InvalidComposeSpecError) as exec_info:
547-
await _perioduc_result(
547+
await _perioduc_result_and_task_removed(
548548
app,
549549
http_client,
550550
await _get_task_id_create_service_containers(
@@ -614,7 +614,7 @@ async def test_containers_down_after_starting(
614614
mocker: MockerFixture,
615615
):
616616
# start containers
617-
result = await _perioduc_result(
617+
result = await _perioduc_result_and_task_removed(
618618
app,
619619
http_client,
620620
await _get_task_id_create_service_containers(
@@ -625,7 +625,7 @@ async def test_containers_down_after_starting(
625625
assert shared_store.container_names == result
626626

627627
# put down containers
628-
result = await _perioduc_result(
628+
result = await _perioduc_result_and_task_removed(
629629
app,
630630
http_client,
631631
await _get_task_id_docker_compose_down(httpx_async_client),
@@ -640,7 +640,7 @@ async def test_containers_down_missing_spec(
640640
app: FastAPI,
641641
caplog_info_debug: pytest.LogCaptureFixture,
642642
):
643-
result = await _perioduc_result(
643+
result = await _perioduc_result_and_task_removed(
644644
app,
645645
http_client,
646646
await _get_task_id_docker_compose_down(httpx_async_client),
@@ -656,7 +656,7 @@ async def test_container_restore_state(
656656
app: FastAPI,
657657
mock_data_manager: None,
658658
):
659-
result = await _perioduc_result(
659+
result = await _perioduc_result_and_task_removed(
660660
app,
661661
http_client,
662662
await _get_task_id_state_restore(httpx_async_client),
@@ -671,7 +671,7 @@ async def test_container_save_state(
671671
app: FastAPI,
672672
mock_data_manager: None,
673673
):
674-
result = await _perioduc_result(
674+
result = await _perioduc_result_and_task_removed(
675675
app,
676676
http_client,
677677
await _get_task_id_state_save(httpx_async_client),
@@ -692,7 +692,7 @@ async def test_container_pull_input_ports(
692692
if inputs_pulling_enabled:
693693
enable_inputs_pulling(app)
694694

695-
result = await _perioduc_result(
695+
result = await _perioduc_result_and_task_removed(
696696
app,
697697
http_client,
698698
await _get_task_id_task_ports_inputs_pull(httpx_async_client, mock_port_keys),
@@ -708,7 +708,7 @@ async def test_container_pull_output_ports(
708708
mock_port_keys: list[str] | None,
709709
mock_nodeports: None,
710710
):
711-
result = await _perioduc_result(
711+
result = await _perioduc_result_and_task_removed(
712712
app,
713713
http_client,
714714
await _get_task_id_task_ports_outputs_pull(httpx_async_client, mock_port_keys),
@@ -724,7 +724,7 @@ async def test_container_push_output_ports(
724724
mock_port_keys: list[str] | None,
725725
mock_nodeports: None,
726726
):
727-
result = await _perioduc_result(
727+
result = await _perioduc_result_and_task_removed(
728728
app,
729729
http_client,
730730
await _get_task_id_task_ports_outputs_push(httpx_async_client, mock_port_keys),
@@ -746,7 +746,7 @@ async def test_container_push_output_ports_missing_node(
746746
await outputs_manager.port_key_content_changed(port_key)
747747

748748
async def _test_code() -> None:
749-
await _perioduc_result(
749+
await _perioduc_result_and_task_removed(
750750
app,
751751
http_client,
752752
await _get_task_id_task_ports_outputs_push(
@@ -772,21 +772,20 @@ async def test_containers_restart(
772772
mock_metrics_params: CreateServiceMetricsAdditionalParams,
773773
shared_store: SharedStore,
774774
):
775-
container_names = await _perioduc_result(
775+
container_names = await _perioduc_result_and_task_removed(
776776
app,
777777
http_client,
778778
await _get_task_id_create_service_containers(
779779
httpx_async_client, compose_spec, mock_metrics_params
780780
),
781781
progress_callback=_debug_progress,
782782
)
783-
assert container_names == shared_store.container_names
784-
assert isinstance(container_names, list)
783+
assert shared_store.container_names == container_names
785784
assert container_names
786785

787786
container_timestamps_before = await _get_container_timestamps(container_names)
788787

789-
result = await _perioduc_result(
788+
result = await _perioduc_result_and_task_removed(
790789
app,
791790
http_client,
792791
await _get_task_id_task_containers_restart(

0 commit comments

Comments
 (0)