From 043eb144f8d579d9b9cc84d4a870f4d770f6e66f Mon Sep 17 00:00:00 2001 From: Aaron Harper Date: Thu, 13 Jun 2024 22:38:20 -0400 Subject: [PATCH] Skip asyncio tests for sync functions --- tests/test_function/cases/__init__.py | 14 +++++++++----- ...asyncio_race.py => asyncio_first_completed.py} | 15 ++------------- tests/test_function/cases/asyncio_gather.py | 15 ++------------- 3 files changed, 13 insertions(+), 31 deletions(-) rename tests/test_function/cases/{asyncio_race.py => asyncio_first_completed.py} (93%) diff --git a/tests/test_function/cases/__init__.py b/tests/test_function/cases/__init__.py index ebba5dd..2e4c301 100644 --- a/tests/test_function/cases/__init__.py +++ b/tests/test_function/cases/__init__.py @@ -2,8 +2,8 @@ from inngest._internal import const from . import ( + asyncio_first_completed, asyncio_gather, - asyncio_race, base, batch_that_needs_api, cancel, @@ -46,7 +46,7 @@ _modules = ( asyncio_gather, - asyncio_race, + asyncio_first_completed, batch_that_needs_api, cancel, change_step_error, @@ -100,9 +100,13 @@ def create_sync_cases( client: inngest.Inngest, framework: const.Framework, ) -> list[base.Case]: - return [ - module.create(client, framework, is_sync=True) for module in _modules - ] + cases = [] + for module in _modules: + case = module.create(client, framework, is_sync=True) + if isinstance(case.fn, list) and len(case.fn) > 1: + cases.append(case) + + return cases __all__ = ["create_async_cases", "create_sync_cases"] diff --git a/tests/test_function/cases/asyncio_race.py b/tests/test_function/cases/asyncio_first_completed.py similarity index 93% rename from tests/test_function/cases/asyncio_race.py rename to tests/test_function/cases/asyncio_first_completed.py index f5664d9..d869c32 100644 --- a/tests/test_function/cases/asyncio_race.py +++ b/tests/test_function/cases/asyncio_first_completed.py @@ -33,18 +33,6 @@ def create( fn_id = base.create_fn_id(test_name) state = _State() - @client.create_function( - fn_id=fn_id, - retries=0, - trigger=inngest.TriggerEvent(event=event_name), - ) - def fn_sync( - ctx: inngest.Context, - step: inngest.StepSync, - ) -> None: - # This test is not applicable for sync functions - pass - @client.create_function( fn_id=f"{fn_id}/child", retries=0, @@ -135,7 +123,8 @@ async def run_test(self: base.TestClass) -> None: assert state.done_result == "fast" if is_sync: - fn = [fn_sync] + # This test is not applicable for sync functions + fn = [] else: fn = [fn_async, fn_child_async] diff --git a/tests/test_function/cases/asyncio_gather.py b/tests/test_function/cases/asyncio_gather.py index 5a9bdf4..5a1ad2e 100644 --- a/tests/test_function/cases/asyncio_gather.py +++ b/tests/test_function/cases/asyncio_gather.py @@ -25,18 +25,6 @@ def create( fn_id = base.create_fn_id(test_name) state = _State() - @client.create_function( - fn_id=fn_id, - retries=0, - trigger=inngest.TriggerEvent(event=event_name), - ) - def fn_sync( - ctx: inngest.Context, - step: inngest.StepSync, - ) -> None: - # This test is not applicable for sync functions - pass - @client.create_function( fn_id=f"{fn_id}/child", retries=0, @@ -116,7 +104,8 @@ async def run_test(self: base.TestClass) -> None: assert state.output == [None, "slow", "fast", None, None, None] if is_sync: - fn = [fn_sync] + # This test is not applicable for sync functions + fn = [] else: fn = [fn_async, fn_child_async]