Skip to content

Commit 4b420b4

Browse files
committed
ensure test passes
1 parent 961a320 commit 4b420b4

File tree

3 files changed

+40
-33
lines changed

3 files changed

+40
-33
lines changed

services/web/server/src/simcore_service_webserver/functions/_functions_repository.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ async def patch_function_job( # noqa: PLR0913
255255
)
256256
result = await transaction.execute(
257257
function_jobs_table.update()
258-
.where(function_jobs_table.c.uuid == registered_function_job_db.uuid)
258+
.where(function_jobs_table.c.uuid == f"{registered_function_job_db.uuid}")
259259
.values(
260260
inputs=registered_function_job_db.inputs,
261261
outputs=registered_function_job_db.outputs,

services/web/server/src/simcore_service_webserver/functions/_functions_service.py

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -121,16 +121,13 @@ async def patch_registered_function_job(
121121

122122
patched_job = _patch_functionjob(job, registered_function_job_patch)
123123

124-
await _functions_repository.patch_function_job(
124+
result = await _functions_repository.patch_function_job(
125125
app=app,
126-
function_job_uuid=function_job_uuid,
127126
user_id=user_id,
128127
product_name=product_name,
129-
title=title,
130-
description=description,
131-
class_specific_data=class_specific_data,
128+
registered_function_job_db=patched_job,
132129
)
133-
return _decode_functionjob(job)
130+
return _decode_functionjob(result)
134131

135132

136133
async def register_function_job_collection(
@@ -762,7 +759,7 @@ def _decode_functionjob(
762759
return RegisteredProjectFunctionJob(
763760
uid=functionjob_db.uuid,
764761
title=functionjob_db.title,
765-
description="",
762+
description=functionjob_db.description,
766763
function_uid=functionjob_db.function_uuid,
767764
inputs=functionjob_db.inputs,
768765
outputs=functionjob_db.outputs,
@@ -777,7 +774,7 @@ def _decode_functionjob(
777774
return RegisteredSolverFunctionJob(
778775
uid=functionjob_db.uuid,
779776
title=functionjob_db.title,
780-
description="",
777+
description=functionjob_db.description,
781778
function_uid=functionjob_db.function_uuid,
782779
inputs=functionjob_db.inputs,
783780
outputs=functionjob_db.outputs,
@@ -809,10 +806,16 @@ def _patch_functionjob(
809806
outputs=function_job_db.outputs,
810807
created=function_job_db.created,
811808
class_specific_data=FunctionClassSpecificData(
812-
project_job_id=patch.project_job_id
813-
or function_job_db.class_specific_data.get("project_job_id"),
814-
job_creation_task_id=patch.job_creation_task_id
815-
or function_job_db.class_specific_data.get("job_creation_task_id"),
809+
project_job_id=(
810+
f"{patch.project_job_id}"
811+
if patch.project_job_id
812+
else function_job_db.class_specific_data.get("project_job_id")
813+
),
814+
job_creation_task_id=(
815+
f"{patch.job_creation_task_id}"
816+
if patch.job_creation_task_id
817+
else function_job_db.class_specific_data.get("job_creation_task_id")
818+
),
816819
),
817820
)
818821
elif function_job_db.function_class == FunctionClass.SOLVER:
@@ -827,10 +830,16 @@ def _patch_functionjob(
827830
outputs=function_job_db.outputs,
828831
created=function_job_db.created,
829832
class_specific_data=FunctionClassSpecificData(
830-
solver_job_id=patch.solver_job_id
831-
or function_job_db.class_specific_data.get("solver_job_id"),
832-
job_creation_task_id=patch.job_creation_task_id
833-
or function_job_db.class_specific_data.get("job_creation_task_id"),
833+
solver_job_id=(
834+
f"{patch.solver_job_id}"
835+
if patch.solver_job_id
836+
else function_job_db.class_specific_data.get("solver_job_id")
837+
),
838+
job_creation_task_id=(
839+
f"{patch.job_creation_task_id}"
840+
if patch.job_creation_task_id
841+
else function_job_db.class_specific_data.get("job_creation_task_id")
842+
),
834843
),
835844
)
836845
elif function_job_db.function_class == FunctionClass.PYTHON_CODE:

services/web/server/tests/unit/with_dbs/04/functions/test_function_jobs_controller_rpc.py

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# pylint: disable=unused-argument
33

44
import datetime
5-
from uuid import UUID, uuid4
5+
from uuid import uuid4
66

77
import pytest
88
from aiohttp.test_utils import TestClient
@@ -16,6 +16,7 @@
1616
FunctionClass,
1717
FunctionJobCollection,
1818
FunctionJobStatus,
19+
RegisteredProjectFunctionJobPatch,
1920
)
2021
from models_library.functions_errors import (
2122
FunctionJobIDNotFoundError,
@@ -24,7 +25,9 @@
2425
FunctionJobWriteAccessDeniedError,
2526
)
2627
from models_library.products import ProductName
28+
from models_library.projects import ProjectID
2729
from pytest_simcore.helpers.webserver_users import UserInfoDict
30+
from servicelib.celery.models import TaskID
2831
from servicelib.rabbitmq import RabbitMQRPCClient
2932
from servicelib.rabbitmq.rpc_interfaces.webserver.functions import (
3033
functions_rpc_interface as functions_rpc,
@@ -474,30 +477,25 @@ async def test_patch_registered_function_jobs(
474477
product_name=osparc_product_name,
475478
)
476479

477-
added_data = {"job_creation_task_id": f"{uuid4()}"}
478-
479-
registered_job = await functions_rpc.patch_registered_function_job(
480-
rabbitmq_rpc_client=rpc_client,
481-
user_id=logged_user["id"],
482-
function_job_uuid=registered_job.uid,
483-
product_name=osparc_product_name,
484-
job_creation_task_id=added_data["job_creation_task_id"],
480+
patch = RegisteredProjectFunctionJobPatch(
481+
title=_faker.word(),
482+
description=_faker.sentence(),
483+
project_job_id=ProjectID(_faker.uuid4()),
484+
job_creation_task_id=TaskID(_faker.uuid4()),
485485
)
486-
assert registered_job.function_class == FunctionClass.PROJECT
487-
assert registered_job.job_creation_task_id == added_data["job_creation_task_id"]
488-
489-
added_data.update(project_job_id=f"{uuid4()}")
490486

491487
registered_job = await functions_rpc.patch_registered_function_job(
492488
rabbitmq_rpc_client=rpc_client,
493489
user_id=logged_user["id"],
494490
function_job_uuid=registered_job.uid,
495491
product_name=osparc_product_name,
496-
project_job_id=added_data["project_job_id"],
492+
registered_function_job_patch=patch,
497493
)
498494
assert registered_job.function_class == FunctionClass.PROJECT
499-
assert registered_job.job_creation_task_id == added_data["job_creation_task_id"]
500-
assert registered_job.project_job_id == UUID(added_data["project_job_id"])
495+
assert registered_job.title == patch.title
496+
assert registered_job.description == patch.description
497+
assert registered_job.job_creation_task_id == patch.job_creation_task_id
498+
assert registered_job.project_job_id == patch.project_job_id
501499

502500

503501
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)