Skip to content

Commit 1d1bb79

Browse files
committed
fix: update RPC namespace from 'webserver' to 'wb-api-server' in job tests
1 parent e7e9666 commit 1d1bb79

File tree

3 files changed

+14
-16
lines changed

3 files changed

+14
-16
lines changed

services/api-server/tests/unit/api_functions/celery/test_functions_celery.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
from models_library.users import UserID
4242
from pytest_mock import MockerFixture, MockType
4343
from pytest_simcore.helpers.httpx_calls_capture_models import HttpApiCallCaptureModel
44+
from pytest_simcore.helpers.typing_mock import HandlerMockFactory
4445
from servicelib.celery.models import ExecutionMetadata, TaskID, TasksQueue
4546
from servicelib.common_headers import (
4647
X_SIMCORE_PARENT_NODE_ID,
@@ -165,9 +166,7 @@ async def test_with_fake_run_function(
165166
auth: BasicAuth,
166167
mocker: MockerFixture,
167168
with_api_server_celery_worker: TestWorkController,
168-
mock_handler_in_functions_rpc_interface: Callable[
169-
[str, Any, Exception | None, Callable | None], None
170-
],
169+
mock_handler_in_functions_rpc_interface: HandlerMockFactory,
171170
fake_registered_project_function: RegisteredProjectFunction,
172171
fake_registered_project_function_job: RegisteredFunctionJob,
173172
user_id: UserID,
@@ -316,9 +315,7 @@ async def test_run_project_function_parent_info(
316315
app: FastAPI,
317316
with_api_server_celery_worker: TestWorkController,
318317
client: AsyncClient,
319-
mock_handler_in_functions_rpc_interface: Callable[
320-
[str, Any, Exception | None, Callable | None], None
321-
],
318+
mock_handler_in_functions_rpc_interface: HandlerMockFactory,
322319
fake_registered_project_function: RegisteredProjectFunction,
323320
fake_registered_project_function_job: RegisteredFunctionJob,
324321
auth: httpx.BasicAuth,
@@ -432,9 +429,7 @@ async def test_map_function_parent_info(
432429
app: FastAPI,
433430
with_api_server_celery_worker: TestWorkController,
434431
client: AsyncClient,
435-
mock_handler_in_functions_rpc_interface: Callable[
436-
[str, Any, Exception | None, Callable | None], MockType
437-
],
432+
mock_handler_in_functions_rpc_interface: HandlerMockFactory,
438433
fake_registered_project_function: RegisteredProjectFunction,
439434
fake_registered_project_function_job: RegisteredFunctionJob,
440435
auth: httpx.BasicAuth,
@@ -556,9 +551,7 @@ async def test_map_function(
556551
app: FastAPI,
557552
with_api_server_celery_worker: TestWorkController,
558553
client: AsyncClient,
559-
mock_handler_in_functions_rpc_interface: Callable[
560-
[str, Any, Exception | None, Callable | None], MockType
561-
],
554+
mock_handler_in_functions_rpc_interface: HandlerMockFactory,
562555
fake_registered_project_function: RegisteredProjectFunction,
563556
fake_registered_project_function_job: RegisteredFunctionJob,
564557
auth: httpx.BasicAuth,

services/api-server/tests/unit/api_solvers/test_api_routers_solvers_jobs_read.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ async def test_list_all_solvers_jobs(
127127
assert mocked_backend.webserver_rpc[
128128
"mocked_rabbit_rpc_client"
129129
].request.call_args.args == (
130-
"webserver",
130+
"wb-api-server",
131131
"list_projects_marked_as_jobs",
132132
)
133133

@@ -173,7 +173,7 @@ async def test_list_all_solvers_jobs_with_metadata_filter(
173173
"mocked_rabbit_rpc_client"
174174
].request.call_args
175175
assert call_args.args == (
176-
"webserver",
176+
"wb-api-server",
177177
"list_projects_marked_as_jobs",
178178
)
179179

services/api-server/tests/unit/service/test_service_solvers.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,17 @@ async def test_job_service_get_job_exceptions(
121121
job_service: JobService,
122122
client_exception_type: type[Exception],
123123
api_exception_type: type[Exception],
124+
mocked_rabbit_rpc_client: MockType,
124125
):
125126
job_parent_resource_name = "solver-resource"
126127
job_id = ProjectID("123e4567-e89b-12d3-a456-426614174000")
128+
127129
# Patch the actual RPC interface method
128-
patch_path = "servicelib.rabbitmq.rpc_interfaces.webserver.projects.get_project_marked_as_job"
129-
mocker.patch(patch_path, side_effect=client_exception_type())
130+
async def _request_side_effect(namespace, method_name, **kwargs):
131+
if namespace == "webserver" and method_name == "get_project_marked_as_job":
132+
raise client_exception_type()
133+
134+
mocked_rabbit_rpc_client.request.side_effect = _request_side_effect
130135

131136
with pytest.raises(api_exception_type):
132137
await job_service.get_job(job_parent_resource_name, job_id)

0 commit comments

Comments
 (0)