Skip to content

Commit

Permalink
Revert "Remove sessions cleaning for data workflows tests (#1788)" (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
doctrino authored Jun 4, 2024
1 parent e5b5570 commit 13b0095
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/tests_integration/test_api/test_data_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,16 @@ def workflow_execution_list(
return cognite_client.workflows.executions.list(workflow_version_ids=add_multiply_workflow.as_id(), limit=5)


@pytest.fixture()
def clean_created_sessions(cognite_client: CogniteClient) -> None:
existing_active_sessions = cognite_client.iam.sessions.list(status="active", limit=-1)
yield None
current_sessions = cognite_client.iam.sessions.list(status="active", limit=-1)
existing_ids = {session.id for session in existing_active_sessions}
to_revoked = [session.id for session in current_sessions if session.id not in existing_ids]
cognite_client.iam.sessions.revoke(to_revoked)


class TestWorkflows:
def test_upsert_delete(self, cognite_client: CogniteClient) -> None:
workflow = WorkflowUpsert(
Expand Down Expand Up @@ -378,6 +388,9 @@ def test_retrieve_non_existing_workflow_execution(self, cognite_client: CogniteC

assert non_existing is None

# Each trigger creates a new execution, so we need to clean up after each test to avoid
# running out of quota
@pytest.mark.usefixtures("clean_created_sessions")
def test_trigger_retrieve_detailed_update_update_task(
self,
cognite_client: CogniteClient,
Expand All @@ -398,6 +411,7 @@ def test_trigger_retrieve_detailed_update_update_task(
async_task = cognite_client.workflows.tasks.update(async_task.id, "completed")
assert async_task.status == "completed"

@pytest.mark.usefixtures("clean_created_sessions")
def test_trigger_cancel_retry_workflow(
self, cognite_client: CogniteClient, add_multiply_workflow: WorkflowVersion
) -> None:
Expand Down

0 comments on commit 13b0095

Please sign in to comment.