diff --git a/tests/common.py b/tests/common.py index 580133e..4a24beb 100644 --- a/tests/common.py +++ b/tests/common.py @@ -270,9 +270,11 @@ class WrappedMessage: assert resp.status_code == 200 assert rjson["id"] == str(self.id) - async def refetch(self) -> dict: + async def refetch(self) -> Optional["WrappedMessage"]: async with self.test_cli.app.app_context(): message_data = await self.test_cli.app.storage.get_message(self.id) + if message_data is None: + return None return WrappedMessage.from_json(self.test_cli, message_data) @classmethod diff --git a/tests/test_channels.py b/tests/test_channels.py index c6a98d4..ccbe84a 100644 --- a/tests/test_channels.py +++ b/tests/test_channels.py @@ -122,3 +122,23 @@ async def test_channel_message_delete_different_author(test_cli_user): headers={"authorization": user.token}, ) assert resp.status_code == 204 + + +async def test_channel_message_bulk_delete(test_cli_user): + guild = await test_cli_user.create_guild() + channel = await test_cli_user.create_guild_channel(guild_id=guild.id) + messages = [] + for _ in range(10): + messages.append( + await test_cli_user.create_message(guild_id=guild.id, channel_id=channel.id) + ) + + resp = await test_cli_user.post( + f"/api/v6/channels/{channel.id}/messages/bulk-delete", + json={"messages": [message.id for message in messages]}, + ) + assert resp.status_code == 204 + + # assert everyone cant be refetched + for message in messages: + assert (await message.refetch()) is None