diff --git a/tests/tests_integration/test_api/test_workflows.py b/tests/tests_integration/test_api/test_workflows.py index a922d64fe7..fbc3f5c7bb 100644 --- a/tests/tests_integration/test_api/test_workflows.py +++ b/tests/tests_integration/test_api/test_workflows.py @@ -9,6 +9,7 @@ from cognite.client.data_classes.workflows import ( CDFTaskParameters, FunctionTaskParameters, + SubworkflowTaskParameters, TransformationTaskParameters, Workflow, WorkflowDefinitionUpsert, @@ -70,13 +71,37 @@ def workflow_version_list(cognite_client: CogniteClient) -> WorkflowVersionList: workflow_definition=WorkflowDefinitionUpsert( tasks=[ WorkflowTask( - external_id=f"{workflow_id}-2-task1", + external_id="subworkflow1", + parameters=SubworkflowTaskParameters( + tasks=[ + WorkflowTask( + external_id="s1-task1", + parameters=CDFTaskParameters( + resource_path="/dummy/no/real/resource/path", + method="GET", + body={"limit": 1}, + ), + ), + WorkflowTask( + external_id="s1-task2", + parameters=CDFTaskParameters( + resource_path="/dummy/no/real/resource/path", + method="GET", + body={"limit": 1}, + ), + ), + ] + ), + ), + WorkflowTask( + external_id="task1", parameters=CDFTaskParameters( resource_path="/dummy/no/real/resource/path", method="GET", body={"limit": 1}, ), - ) + depends_on=["subworkflow1"], + ), ], description=None, ), @@ -106,7 +131,10 @@ def handle(client, data: dict): return output cognite_client.functions.create(name="Add", external_id=external_id, function_handle=handle) - pytest.skip("Function need to be redeployed, skipping tests that need it", allow_module_level=True) + pytest.skip( + "Function need to be redeployed, skipping tests that need it", + allow_module_level=True, + ) @pytest.fixture(scope="session") @@ -122,7 +150,10 @@ def handle(client, data: dict): return output cognite_client.functions.create(name="Multiply", external_id=external_id, function_handle=handle) - pytest.skip("Function need to be redeployed, skipping tests that need it", allow_module_level=True) + pytest.skip( + "Function need to be redeployed, skipping tests that need it", + allow_module_level=True, + ) @pytest.fixture @@ -171,7 +202,9 @@ def workflow_execution_list( return executions # Creating at least one execution result = cognite_client.workflows.executions.trigger( - add_multiply_workflow.workflow_external_id, add_multiply_workflow.version, {"a": 5, "b": 6} + add_multiply_workflow.workflow_external_id, + add_multiply_workflow.version, + {"a": 5, "b": 6}, ) t0 = time.time() while result.status != "completed": @@ -274,14 +307,16 @@ def test_list_workflow_version_limit( def test_delete_non_existing_raise(self, cognite_client: CogniteClient) -> None: with pytest.raises(CogniteAPIError) as e: cognite_client.workflows.versions.delete( - ("integration_test-non_existing_workflow_version", "1"), ignore_unknown_ids=False + ("integration_test-non_existing_workflow_version", "1"), + ignore_unknown_ids=False, ) assert "not found" in str(e.value) def test_delete_non_existing(self, cognite_client: CogniteClient) -> None: cognite_client.workflows.versions.delete( - ("integration_test-non_existing_workflow_version", "1"), ignore_unknown_ids=True + ("integration_test-non_existing_workflow_version", "1"), + ignore_unknown_ids=True, ) def test_retrieve_workflow(self, cognite_client: CogniteClient, workflow_version_list: WorkflowVersionList) -> None: @@ -299,7 +334,9 @@ def test_retrieve_non_existing_workflow(self, cognite_client: CogniteClient) -> class TestWorkflowExecutions: def test_list_workflow_executions( - self, cognite_client: CogniteClient, workflow_execution_list: WorkflowExecutionList + self, + cognite_client: CogniteClient, + workflow_execution_list: WorkflowExecutionList, ) -> None: workflow_ids = set(w.as_workflow_id() for w in workflow_execution_list) @@ -311,7 +348,9 @@ def test_list_workflow_executions( assert all(w.as_workflow_id() in workflow_ids for w in listed) def test_retrieve_workflow_execution_detailed( - self, cognite_client: CogniteClient, workflow_execution_list: WorkflowExecutionList + self, + cognite_client: CogniteClient, + workflow_execution_list: WorkflowExecutionList, ) -> None: retrieved = cognite_client.workflows.executions.retrieve_detailed(workflow_execution_list[0].id)