|
11 | 11 | from pytest_mock import MockType |
12 | 12 | from simcore_service_api_server._service_jobs import JobService |
13 | 13 | from simcore_service_api_server._service_solvers import SolverService |
| 14 | +from simcore_service_api_server.exceptions.backend_errors import ( |
| 15 | + JobForbiddenAccessError, |
| 16 | + JobNotFoundError, |
| 17 | +) |
14 | 18 | from simcore_service_api_server.exceptions.custom_errors import ( |
15 | 19 | ServiceConfigurationError, |
16 | 20 | ) |
@@ -107,20 +111,23 @@ async def test_job_service_get_job_success( |
107 | 111 |
|
108 | 112 |
|
109 | 113 | @pytest.mark.parametrize( |
110 | | - "exception_type", |
111 | | - [ProjectForbiddenRpcError, ProjectNotFoundRpcError], |
| 114 | + "client_exception_type,api_exception_type", |
| 115 | + [ |
| 116 | + (ProjectForbiddenRpcError, JobForbiddenAccessError), |
| 117 | + (ProjectNotFoundRpcError, JobNotFoundError), |
| 118 | + ], |
112 | 119 | ) |
113 | 120 | async def test_job_service_get_job_exceptions( |
114 | | - mocker, job_service: JobService, exception_type |
| 121 | + mocker, |
| 122 | + job_service: JobService, |
| 123 | + client_exception_type: type[Exception], |
| 124 | + api_exception_type: type[Exception], |
115 | 125 | ): |
116 | 126 | job_parent_resource_name = "solver-resource" |
117 | 127 | job_id = ProjectID("123e4567-e89b-12d3-a456-426614174000") |
118 | | - mocker.patch.object( |
119 | | - job_service._web_rpc_client, |
120 | | - "get_project_marked_as_job", |
121 | | - side_effect=exception_type("error"), |
122 | | - ) |
| 128 | + # Patch the actual RPC interface method |
| 129 | + patch_path = "servicelib.rabbitmq.rpc_interfaces.webserver.projects.get_project_marked_as_job" |
| 130 | + mocker.patch(patch_path, side_effect=client_exception_type()) |
123 | 131 |
|
124 | | - with pytest.raises(exception_type): |
125 | | - await job_service.get_job(job_parent_resource_name, job_id) |
| 132 | + with pytest.raises(api_exception_type): |
126 | 133 | await job_service.get_job(job_parent_resource_name, job_id) |
0 commit comments