tests: add test for different member deleting own message

This commit is contained in:
Luna 2021-09-06 00:14:43 -03:00
parent e5691e1362
commit 866accb45f
1 changed files with 19 additions and 0 deletions

View File

@ -18,6 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
""" """
import pytest import pytest
from litecord.common.guilds import add_member
pytestmark = pytest.mark.asyncio pytestmark = pytest.mark.asyncio
@ -84,3 +85,21 @@ async def test_channel_message_delete(test_cli_user):
f"/api/v6/channels/{channel.id}/messages/{message.id}", f"/api/v6/channels/{channel.id}/messages/{message.id}",
) )
assert resp.status_code == 204 assert resp.status_code == 204
async def test_channel_message_delete_different_author(test_cli_user):
guild = await test_cli_user.create_guild()
channel = await test_cli_user.create_guild_channel(guild_id=guild.id)
user = await test_cli_user.create_user()
async with test_cli_user.app.app_context():
await add_member(guild.id, user.id)
message = await test_cli_user.create_message(
guild_id=guild.id, channel_id=channel.id, author_id=user.id
)
resp = await test_cli_user.delete(
f"/api/v6/channels/{channel.id}/messages/{message.id}",
headers={"authorization": user.token},
)
assert resp.status_code == 204