Skip to content

Commit 99fa661

Browse files
chore: Fix flaky functions test (#2327)
1 parent 9c27611 commit 99fa661

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

tests/tests_integration/test_api/test_functions.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,12 +199,23 @@ def test_raise_retrieve_unknown(self, cognite_client: CogniteClient) -> None:
199199
cognite_client.functions.schedules.retrieve(id=[123])
200200
assert cognite_client.functions.schedules.retrieve(id=123) is None
201201

202-
def test_create_with_nonce(self, cognite_client: CogniteClient, dummy_function: Function) -> None:
202+
def test_create_with_nonce(self, cognite_client: CogniteClient) -> None:
203203
session = cognite_client.iam.sessions.create(session_type="ONESHOT_TOKEN_EXCHANGE")
204+
205+
def handle(client, data, secrets, function_call_info):
206+
print(f"Inputs: {data!r}") # noqa
207+
print(f"Call info: {function_call_info!r}") # noqa
208+
return data
209+
210+
created_fn = cognite_client.functions.create(
211+
name="test_function_for_schedule_with_nonce",
212+
function_handle=handle,
213+
description="print inputs & call info, return inputs",
214+
)
204215
schedule = FunctionScheduleWrite(
205216
name="test_create_with_nonce",
206217
cron_expression="0 0 * * *",
207-
function_id=dummy_function.id,
218+
function_id=created_fn.id,
208219
data={"key": "value"},
209220
nonce=session.nonce,
210221
)
@@ -220,3 +231,5 @@ def test_create_with_nonce(self, cognite_client: CogniteClient, dummy_function:
220231
finally:
221232
if created:
222233
cognite_client.functions.schedules.delete(created.id)
234+
if created_fn:
235+
cognite_client.functions.delete(id=created_fn.id)

0 commit comments

Comments
 (0)