Skip to content

Commit

Permalink
Make more robust workflow tests (#1716)
Browse files Browse the repository at this point in the history
  • Loading branch information
doctrino committed Apr 12, 2024
1 parent b18ec1e commit a5d98fe
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions tests/tests_integration/test_api/test_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,12 @@ def add_multiply_workflow(
],
),
)
# Delete existing workflow and versions
cognite_client.workflows.delete(workflow_id, ignore_unknown_ids=True)
yield cognite_client.workflows.versions.upsert(version)
cognite_client.workflows.delete(workflow_id, ignore_unknown_ids=True)

retrieved = cognite_client.workflows.versions.retrieve(version.workflow_external_id, version.version)
if retrieved is not None:
return retrieved
else:
return cognite_client.workflows.versions.upsert(version)


@pytest.fixture(scope="session")
Expand Down Expand Up @@ -360,6 +362,7 @@ def test_list_workflow_executions(
) -> None:
workflow_ids = set(w.as_workflow_id() for w in workflow_execution_list)

assert workflow_ids, "There should be at least one workflow execution to test list with"
listed = cognite_client.workflows.executions.list(
workflow_version_ids=list(workflow_ids), limit=len(workflow_execution_list)
)
Expand All @@ -372,6 +375,7 @@ def test_retrieve_workflow_execution_detailed(
cognite_client: CogniteClient,
workflow_execution_list: WorkflowExecutionList,
) -> None:
assert workflow_execution_list, "There should be at least one workflow execution to test retrieve detailed with"
retrieved = cognite_client.workflows.executions.retrieve_detailed(workflow_execution_list[0].id)

assert retrieved.as_execution().dump() == workflow_execution_list[0].dump()
Expand Down

0 comments on commit a5d98fe

Please sign in to comment.