Skip to content

Commit c4d69ed

Browse files
author
Andrei Neagu
committed
fixed tests
1 parent 5868e41 commit c4d69ed

File tree

5 files changed

+16
-2
lines changed

5 files changed

+16
-2
lines changed

services/dynamic-sidecar/src/simcore_service_dynamic_sidecar/modules/long_running_tasks_utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ async def run_before_shutdown_actions(
5151
async def ensure_read_permissions_on_user_service_data(
5252
mounted_volumes: MountedVolumes,
5353
) -> None:
54-
# make sure sidecar has access to the files and that the user did not accidetally remove read access
54+
# Makes sure sidecar has access to all files in the user services.
55+
# The user could have removed read permissions form a file, which will cause an error.
56+
5557
# NOTE: command runs inside self container since the user service container might not always be running
5658
self_container = os.environ["HOSTNAME"]
5759
for path_to_store in ( # apply changes to otuputs and all state folders

services/dynamic-sidecar/tests/unit/conftest.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from aiodocker.volumes import DockerVolume
1212
from async_asgi_testclient import TestClient
1313
from fastapi import FastAPI
14+
from pytest_mock.plugin import MockerFixture
1415
from pytest_simcore.helpers.monkeypatch_envs import EnvVarsDict, setenvs_from_dict
1516
from simcore_service_dynamic_sidecar.core.application import AppState, create_app
1617
from simcore_service_dynamic_sidecar.core.docker_compose_utils import (
@@ -157,3 +158,10 @@ def port_notifier(app: FastAPI) -> PortNotifier:
157158
settings.DY_SIDECAR_PROJECT_ID,
158159
settings.DY_SIDECAR_NODE_ID,
159160
)
161+
162+
163+
@pytest.fixture
164+
def mock_ensure_read_permissions_on_user_service_data(mocker: MockerFixture) -> None:
165+
mocker.patch(
166+
"simcore_service_dynamic_sidecar.modules.long_running_tasks.ensure_read_permissions_on_user_service_data",
167+
)

services/dynamic-sidecar/tests/unit/test_api_rest_containers_long_running_tasks.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,7 @@ def _get_awaitable() -> Awaitable:
520520

521521

522522
async def test_containers_down_after_starting(
523+
mock_ensure_read_permissions_on_user_service_data: None,
523524
httpx_async_client: AsyncClient,
524525
client: Client,
525526
compose_spec: str,

services/dynamic-sidecar/tests/unit/test_api_rest_workflow_service_metrics.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ async def _get_task_id_docker_compose_down(httpx_async_client: AsyncClient) -> T
172172

173173

174174
def _get_resource_tracking_messages(
175-
mock_core_rabbitmq: dict[str, AsyncMock]
175+
mock_core_rabbitmq: dict[str, AsyncMock],
176176
) -> list[RabbitResourceTrackingMessages]:
177177
return [
178178
x[0][1]
@@ -200,6 +200,7 @@ async def _wait_for_containers_to_be_running(app: FastAPI) -> None:
200200

201201

202202
async def test_service_starts_and_closes_as_expected(
203+
mock_ensure_read_permissions_on_user_service_data: None,
203204
mock_core_rabbitmq: dict[str, AsyncMock],
204205
app: FastAPI,
205206
httpx_async_client: AsyncClient,
@@ -383,6 +384,7 @@ async def _mocked_get_container_states(
383384

384385
@pytest.mark.parametrize("expected_platform_state", SimcorePlatformStatus)
385386
async def test_user_services_crash_when_running(
387+
mock_ensure_read_permissions_on_user_service_data: None,
386388
mock_core_rabbitmq: dict[str, AsyncMock],
387389
app: FastAPI,
388390
httpx_async_client: AsyncClient,

services/dynamic-sidecar/tests/unit/test_modules_attribute_monitor.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ async def logging_event_handler_observer(
125125
],
126126
)
127127
async def test_chown_triggers_event(
128+
mock_ensure_read_permissions_on_user_service_data: None,
128129
logging_event_handler_observer: None,
129130
fake_dy_volumes_mount_dir: Path,
130131
command_template: str,

0 commit comments

Comments
 (0)