|
6 | 6 | from celery.contrib.testing.worker import TestWorkController |
7 | 7 | from celery_library.task import register_task |
8 | 8 | from faker import Faker |
| 9 | +from fastapi import FastAPI |
| 10 | +from httpx import AsyncClient, BasicAuth |
9 | 11 | from models_library.functions import ( |
10 | 12 | FunctionClass, |
11 | 13 | FunctionID, |
12 | 14 | FunctionInputs, |
13 | 15 | FunctionJobID, |
14 | 16 | RegisteredFunction, |
| 17 | + RegisteredProjectFunction, |
15 | 18 | RegisteredProjectFunctionJob, |
16 | 19 | ) |
17 | 20 | from models_library.projects import ProjectID |
18 | 21 | from servicelib.celery.models import TaskID |
| 22 | +from servicelib.common_headers import ( |
| 23 | + X_SIMCORE_PARENT_NODE_ID, |
| 24 | + X_SIMCORE_PARENT_PROJECT_UUID, |
| 25 | +) |
| 26 | +from simcore_service_api_server._meta import API_VTAG |
19 | 27 | from simcore_service_api_server.api.dependencies.authentication import Identity |
| 28 | +from simcore_service_api_server.api.routes.functions_routes import get_function |
20 | 29 | from simcore_service_api_server.celery._worker_tasks._functions_tasks import ( |
21 | 30 | run_function as run_function_task, |
22 | 31 | ) |
@@ -72,5 +81,28 @@ def _(celery_app: Celery) -> None: |
72 | 81 |
|
73 | 82 | @pytest.mark.parametrize("register_celery_tasks", [_register_fake_run_function_task()]) |
74 | 83 | @pytest.mark.parametrize("add_worker_tasks", [False]) |
75 | | -async def test_with_fake_run_function(with_storage_celery_worker: TestWorkController): |
76 | | - pass |
| 84 | +async def test_with_fake_run_function( |
| 85 | + app: FastAPI, |
| 86 | + client: AsyncClient, |
| 87 | + auth: BasicAuth, |
| 88 | + with_storage_celery_worker: TestWorkController, |
| 89 | +): |
| 90 | + |
| 91 | + extra = RegisteredProjectFunction.model_config.get("json_schema_extra") |
| 92 | + assert extra |
| 93 | + app.dependency_overrides[get_function] = ( |
| 94 | + lambda: RegisteredProjectFunction.model_validate(extra["examples"][0]) |
| 95 | + ) |
| 96 | + |
| 97 | + headers = {} |
| 98 | + headers[X_SIMCORE_PARENT_PROJECT_UUID] = "null" |
| 99 | + headers[X_SIMCORE_PARENT_NODE_ID] = "null" |
| 100 | + |
| 101 | + response = await client.post( |
| 102 | + f"/{API_VTAG}/functions/{_faker.uuid4()}:run", |
| 103 | + auth=auth, |
| 104 | + json={}, |
| 105 | + headers=headers, |
| 106 | + ) |
| 107 | + |
| 108 | + assert response.status_code == 200 |
0 commit comments