mirror of https://gitlab.com/litecord/litecord.git
tests: add test for bulk deletes
This commit is contained in:
parent
415f1fa3be
commit
8da480db88
|
|
@ -270,9 +270,11 @@ class WrappedMessage:
|
||||||
assert resp.status_code == 200
|
assert resp.status_code == 200
|
||||||
assert rjson["id"] == str(self.id)
|
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():
|
async with self.test_cli.app.app_context():
|
||||||
message_data = await self.test_cli.app.storage.get_message(self.id)
|
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)
|
return WrappedMessage.from_json(self.test_cli, message_data)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
|
||||||
|
|
@ -122,3 +122,23 @@ async def test_channel_message_delete_different_author(test_cli_user):
|
||||||
headers={"authorization": user.token},
|
headers={"authorization": user.token},
|
||||||
)
|
)
|
||||||
assert resp.status_code == 204
|
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
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue