diff --git a/stream_chat/tests/async_chat/conftest.py b/stream_chat/tests/async_chat/conftest.py index ddb4486..ff9ad0a 100644 --- a/stream_chat/tests/async_chat/conftest.py +++ b/stream_chat/tests/async_chat/conftest.py @@ -44,6 +44,32 @@ async def client(): timeout=10, **options, ) as stream_client: + # Reset the shared CI test app to a permissive upload + command + # config so tests aren't held hostage to whatever a prior PR left + # behind. Empty allow/block lists on every gate (extensions AND MIME + # types) means 'no restrictions' per backend FileUploadConfig.Validate + # in controllers/types.go. Re-registering the default messaging + # channel-type commands keeps /giphy parseable for run_message_action. + permissive = { + "allowed_file_extensions": [], + "blocked_file_extensions": [], + "allowed_mime_types": [], + "blocked_mime_types": [], + } + try: + await stream_client.update_app_settings( + file_upload_config=permissive, + image_upload_config=permissive, + ) + except Exception: + pass + try: + await stream_client.update_channel_type( + "messaging", + commands=["giphy", "imgur", "flag", "ban", "mute", "unban", "unmute"], + ) + except Exception: + pass yield stream_client diff --git a/stream_chat/tests/async_chat/test_client.py b/stream_chat/tests/async_chat/test_client.py index 94a6efa..25ecd46 100644 --- a/stream_chat/tests/async_chat/test_client.py +++ b/stream_chat/tests/async_chat/test_client.py @@ -174,7 +174,7 @@ async def test_delete_users(self, client: StreamChatAsync, random_user: Dict): ) assert "task_id" in response - for _ in range(60): + for _ in range(300): response = await client.get_task(response["task_id"]) if response["status"] == "completed" and response["result"][ random_user["id"] @@ -669,7 +669,9 @@ async def test_create_blocklist(self, client: StreamChatAsync): async def test_list_blocklists(self, client: StreamChatAsync): response = await client.list_blocklists() - assert len(response["blocklists"]) == 3 + # Don't pin the exact count: the shared test app accumulates blocklists + # across CI runs where teardown didn't get to run. + assert len(response["blocklists"]) >= 3 blocklist_names = {blocklist["name"] for blocklist in response["blocklists"]} assert "Foo" in blocklist_names @@ -811,7 +813,7 @@ async def test_delete_channels(self, client: StreamChatAsync, channel: Channel): response = await client.delete_channels([channel.cid]) assert "task_id" in response - for _ in range(60): + for _ in range(300): response = await client.get_task(response["task_id"]) if response["status"] == "completed" and response["result"][ channel.cid diff --git a/stream_chat/tests/conftest.py b/stream_chat/tests/conftest.py index b18ebda..0796a98 100644 --- a/stream_chat/tests/conftest.py +++ b/stream_chat/tests/conftest.py @@ -25,16 +25,53 @@ def pytest_configure(config): config.addinivalue_line("markers", "incremental: mark test incremental") +def _baseline_app_config(stream_client: StreamChat) -> None: + """Reset the shared CI test app to a permissive upload + command config. + + Pinning state here is safer than skip-on-error guards inside individual + tests — those silently mask drift. Empty allow/block lists on every gate + (extensions AND MIME types) means 'no restrictions' per backend + ``FileUploadConfig.Validate`` in ``controllers/types.go``. Re-registering + the default ``messaging`` channel-type commands keeps ``/giphy`` + parseable for ``run_message_action``. + + Best-effort: a test app that doesn't expose either endpoint falls + through and the individual tests surface the real failure. + """ + permissive = { + "allowed_file_extensions": [], + "blocked_file_extensions": [], + "allowed_mime_types": [], + "blocked_mime_types": [], + } + try: + stream_client.update_app_settings( + file_upload_config=permissive, + image_upload_config=permissive, + ) + except Exception: + pass + try: + stream_client.update_channel_type( + "messaging", + commands=["giphy", "imgur", "flag", "ban", "mute", "unban", "unmute"], + ) + except Exception: + pass + + @pytest.fixture(scope="module") def client(): base_url = os.environ.get("STREAM_HOST") options = {"base_url": base_url} if base_url else {} - return StreamChat( + stream_client = StreamChat( api_key=os.environ["STREAM_KEY"], api_secret=os.environ["STREAM_SECRET"], timeout=10, **options, ) + _baseline_app_config(stream_client) + return stream_client @pytest.fixture(scope="function") diff --git a/stream_chat/tests/test_client.py b/stream_chat/tests/test_client.py index 2a11918..25b1e5a 100644 --- a/stream_chat/tests/test_client.py +++ b/stream_chat/tests/test_client.py @@ -229,7 +229,7 @@ def test_delete_users(self, client: StreamChat, random_user: Dict): ) assert "task_id" in response - for _ in range(60): + for _ in range(300): response = client.get_task(response["task_id"]) if response["status"] == "completed" and response["result"][ random_user["id"] @@ -689,7 +689,9 @@ def test_create_blocklist(self, client: StreamChat): def test_list_blocklists(self, client: StreamChat): response = client.list_blocklists() - assert len(response["blocklists"]) == 3 + # Don't pin the exact count: the shared test app accumulates blocklists + # across CI runs where teardown didn't get to run. + assert len(response["blocklists"]) >= 3 blocklist_names = {blocklist["name"] for blocklist in response["blocklists"]} assert "Foo" in blocklist_names @@ -829,7 +831,7 @@ def test_delete_channels(self, client: StreamChat, channel: Channel): response = client.delete_channels([channel.cid]) assert "task_id" in response - for _ in range(60): + for _ in range(300): response = client.get_task(response["task_id"]) if response["status"] == "completed" and response["result"][ channel.cid