From 480bddc9d82fd108e3c02217506b66a24aea3e32 Mon Sep 17 00:00:00 2001 From: Andrew Hand Date: Fri, 16 Aug 2024 11:54:15 -0400 Subject: [PATCH 1/2] build(restapi): Changed entrypoints to expect no queues in post --- src/dioptra/restapi/v1/entrypoints/schema.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/dioptra/restapi/v1/entrypoints/schema.py b/src/dioptra/restapi/v1/entrypoints/schema.py index af0220c11..ad0bf8c2d 100644 --- a/src/dioptra/restapi/v1/entrypoints/schema.py +++ b/src/dioptra/restapi/v1/entrypoints/schema.py @@ -154,8 +154,10 @@ class EntrypointMutableFieldsSchema(Schema): fields.Integer(), attribute="queue_ids", data_key="queues", + allow_none=True, metadata=dict(description="The queue for the entrypoint."), load_only=True, + load_default=list(), ) From af63c1cb627bcf530b7707fe8c586c1ee70a3a15 Mon Sep 17 00:00:00 2001 From: Andrew Hand Date: Fri, 16 Aug 2024 11:54:51 -0400 Subject: [PATCH 2/2] tests(restapi): Updated test coverage to confirm entrypoints can be registered without queues --- tests/unit/restapi/lib/actions.py | 6 ++++-- tests/unit/restapi/v1/test_entrypoint.py | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/tests/unit/restapi/lib/actions.py b/tests/unit/restapi/lib/actions.py index b7f10c6f7..10734d5cf 100644 --- a/tests/unit/restapi/lib/actions.py +++ b/tests/unit/restapi/lib/actions.py @@ -66,7 +66,7 @@ def register_entrypoint( task_graph: str, parameters: list[dict[str, Any]], plugin_ids: list[int], - queue_ids: list[int], + queue_ids: list[int] | None = None, ) -> TestResponse: """Register an entrypoint using the API. @@ -87,9 +87,11 @@ def register_entrypoint( "taskGraph": task_graph, "parameters": parameters, "plugins": plugin_ids, - "queues": queue_ids, } + if queue_ids: + payload["queues"] = queue_ids + if description: payload["description"] = description diff --git a/tests/unit/restapi/v1/test_entrypoint.py b/tests/unit/restapi/v1/test_entrypoint.py index 4bf089aea..003e80602 100644 --- a/tests/unit/restapi/v1/test_entrypoint.py +++ b/tests/unit/restapi/v1/test_entrypoint.py @@ -549,6 +549,21 @@ def test_create_entrypoint( queue_ids=queue_ids, ) + # Testing that queue_ids feild can be excluded + entrypoint_response = actions.register_entrypoint( + client, + name="queues_not_included", + description=description, + group_id=group_id, + task_graph=task_graph, + parameters=parameters, + plugin_ids=plugin_ids, + ) + entrypoint_expected = entrypoint_response.get_json() + assert_retrieving_entrypoint_by_id_works( + client, entrypoint_id=entrypoint_expected["id"], expected=entrypoint_expected + ) + def test_entrypoint_get_all( dioptra_client: DioptraClient[DioptraResponseProtocol],