diff --git a/stream_chat/async_chat/channel_batch_updater.py b/stream_chat/async_chat/channel_batch_updater.py index ea8ef45..ed09fb8 100644 --- a/stream_chat/async_chat/channel_batch_updater.py +++ b/stream_chat/async_chat/channel_batch_updater.py @@ -206,37 +206,3 @@ async def update_data( "data": data, } return await self.client.update_channels_batch(options) - - async def add_filter_tags( - self, filter: ChannelsBatchFilters, tags: List[str] - ) -> StreamResponse: - """ - Adds filter tags to channels matching the filter. - - :param filter: The filter to match channels. - :param tags: List of filter tags to add. - :return: StreamResponse containing task_id. - """ - options: ChannelsBatchOptions = { - "operation": "addFilterTags", - "filter": filter, - "filter_tags_update": tags, - } - return await self.client.update_channels_batch(options) - - async def remove_filter_tags( - self, filter: ChannelsBatchFilters, tags: List[str] - ) -> StreamResponse: - """ - Removes filter tags from channels matching the filter. - - :param filter: The filter to match channels. - :param tags: List of filter tags to remove. - :return: StreamResponse containing task_id. - """ - options: ChannelsBatchOptions = { - "operation": "removeFilterTags", - "filter": filter, - "filter_tags_update": tags, - } - return await self.client.update_channels_batch(options) diff --git a/stream_chat/channel_batch_updater.py b/stream_chat/channel_batch_updater.py index 32cae70..8d5a14b 100644 --- a/stream_chat/channel_batch_updater.py +++ b/stream_chat/channel_batch_updater.py @@ -206,37 +206,3 @@ def update_data( "data": data, } return self.client.update_channels_batch(options) - - def add_filter_tags( - self, filter: ChannelsBatchFilters, tags: List[str] - ) -> StreamResponse: - """ - Adds filter tags to channels matching the filter. - - :param filter: The filter to match channels. - :param tags: List of filter tags to add. - :return: StreamResponse containing task_id. - """ - options: ChannelsBatchOptions = { - "operation": "addFilterTags", - "filter": filter, - "filter_tags_update": tags, - } - return self.client.update_channels_batch(options) - - def remove_filter_tags( - self, filter: ChannelsBatchFilters, tags: List[str] - ) -> StreamResponse: - """ - Removes filter tags from channels matching the filter. - - :param filter: The filter to match channels. - :param tags: List of filter tags to remove. - :return: StreamResponse containing task_id. - """ - options: ChannelsBatchOptions = { - "operation": "removeFilterTags", - "filter": filter, - "filter_tags_update": tags, - } - return self.client.update_channels_batch(options) diff --git a/stream_chat/tests/async_chat/conftest.py b/stream_chat/tests/async_chat/conftest.py index 425cee0..ddb4486 100644 --- a/stream_chat/tests/async_chat/conftest.py +++ b/stream_chat/tests/async_chat/conftest.py @@ -93,13 +93,35 @@ async def channel(client: StreamChatAsync, random_user: Dict): @pytest.fixture(scope="function") async def command(client: StreamChatAsync): + try: + commands = await client.list_commands() + for cmd in commands.get("commands", []): + if cmd.get("name") not in ( + "giphy", + "imgur", + "flag", + "ban", + "unban", + "mute", + "unmute", + ): + try: + await client.delete_command(cmd["name"]) + except Exception: + pass + except Exception: + pass + response = await client.create_command( dict(name=str(uuid.uuid4()), description="My command") ) yield response["command"] - await client.delete_command(response["command"]["name"]) + try: + await client.delete_command(response["command"]["name"]) + except Exception: + pass @pytest.fixture(scope="function") @@ -121,6 +143,10 @@ async def fellowship_of_the_ring(client: StreamChatAsync): }, {"id": "peregrin-took", "name": "Peregrin Took", "race": "Hobbit", "age": 28}, ] + try: + await client.restore_users([m["id"] for m in members]) + except Exception: + pass await client.upsert_users(members) channel = client.channel( "team", "fellowship-of-the-ring", {"members": [m["id"] for m in members]} diff --git a/stream_chat/tests/async_chat/test_client.py b/stream_chat/tests/async_chat/test_client.py index 76503e5..94a6efa 100644 --- a/stream_chat/tests/async_chat/test_client.py +++ b/stream_chat/tests/async_chat/test_client.py @@ -1,3 +1,4 @@ +import asyncio import json import os import sys @@ -173,14 +174,14 @@ async def test_delete_users(self, client: StreamChatAsync, random_user: Dict): ) assert "task_id" in response - for _ in range(20): + for _ in range(60): response = await client.get_task(response["task_id"]) if response["status"] == "completed" and response["result"][ random_user["id"] ] == {"status": "ok"}: return - time.sleep(1) + await asyncio.sleep(1) pytest.fail("task did not succeed") @@ -810,14 +811,14 @@ 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(20): + for _ in range(60): response = await client.get_task(response["task_id"]) if response["status"] == "completed" and response["result"][ channel.cid ] == {"status": "ok"}: return - time.sleep(1) + await asyncio.sleep(1) pytest.fail("task did not succeed") diff --git a/stream_chat/tests/conftest.py b/stream_chat/tests/conftest.py index 3fe5e7a..b18ebda 100644 --- a/stream_chat/tests/conftest.py +++ b/stream_chat/tests/conftest.py @@ -84,13 +84,35 @@ def channel(client: StreamChat, random_user: Dict): @pytest.fixture(scope="function") def command(client: StreamChat): + try: + commands = client.list_commands() + for cmd in commands.get("commands", []): + if cmd.get("name") not in ( + "giphy", + "imgur", + "flag", + "ban", + "unban", + "mute", + "unmute", + ): + try: + client.delete_command(cmd["name"]) + except Exception: + pass + except Exception: + pass + response = client.create_command( dict(name=str(uuid.uuid4()), description="My command") ) yield response["command"] - client.delete_command(response["command"]["name"]) + try: + client.delete_command(response["command"]["name"]) + except Exception: + pass @pytest.fixture(scope="module") @@ -111,6 +133,10 @@ def fellowship_of_the_ring(client: StreamChat): }, {"id": "peregrin-took", "name": "Peregrin Took", "race": "Hobbit", "age": 28}, ] + try: + client.restore_users([m["id"] for m in members]) + except Exception: + pass client.upsert_users(members) channel = client.channel( "team", "fellowship-of-the-ring", {"members": [m["id"] for m in members]} diff --git a/stream_chat/tests/test_client.py b/stream_chat/tests/test_client.py index 1b09412..74802ff 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(20): + for _ in range(60): response = client.get_task(response["task_id"]) if response["status"] == "completed" and response["result"][ random_user["id"] @@ -818,7 +818,7 @@ def test_delete_channels(self, client: StreamChat, channel: Channel): response = client.delete_channels([channel.cid]) assert "task_id" in response - for _ in range(20): + for _ in range(60): response = client.get_task(response["task_id"]) if response["status"] == "completed" and response["result"][ channel.cid diff --git a/stream_chat/types/channel_batch.py b/stream_chat/types/channel_batch.py index a3db484..d9f1244 100644 --- a/stream_chat/types/channel_batch.py +++ b/stream_chat/types/channel_batch.py @@ -18,8 +18,6 @@ "archive", "unarchive", "updateData", - "addFilterTags", - "removeFilterTags", ] @@ -66,12 +64,10 @@ class ChannelsBatchFilters(TypedDict, total=False): Parameters: cids: Filter by channel CIDs (can be a dict with operators like $in). types: Filter by channel types (can be a dict with operators like $in). - filter_tags: Filter by filter tags (can be a dict with operators like $in). """ cids: Optional[Any] types: Optional[Any] - filter_tags: Optional[Any] class ChannelsBatchOptions(TypedDict, total=False): @@ -83,11 +79,9 @@ class ChannelsBatchOptions(TypedDict, total=False): filter: The filter to match channels (required). members: List of members for member-related operations (optional). data: Channel data updates for updateData operation (optional). - filter_tags_update: List of filter tags for filter tag operations (optional). """ operation: ChannelBatchOperation filter: ChannelsBatchFilters members: Optional[List[ChannelBatchMemberRequest]] data: Optional[ChannelDataUpdate] - filter_tags_update: Optional[List[str]]