From 63d451f2d0b4b58aada3878f496df70945ceb2c8 Mon Sep 17 00:00:00 2001 From: Luna Date: Thu, 16 Sep 2021 21:57:49 -0300 Subject: [PATCH] add test for webhook execution --- tests/test_webhooks.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/test_webhooks.py b/tests/test_webhooks.py index 8193d78..e73c615 100644 --- a/tests/test_webhooks.py +++ b/tests/test_webhooks.py @@ -34,3 +34,19 @@ async def test_webhook_flow(test_cli_user): assert rjson["channel_id"] == str(channel.id) assert rjson["guild_id"] == str(guild.id) assert rjson["name"] == "awooga" + + webhook_id = rjson["id"] + webhook_token = rjson["token"] + + resp = await test_cli_user.post( + f"/api/v6/webhooks/{webhook_id}/{webhook_token}", + json={"content": "test_message"}, + headers={"authorization": ""}, + ) + assert resp.status_code == 204 + + refetched_channel = await channel.refetch() + message = await test_cli_user.app.storage.get_message( + refetched_channel.last_message_id + ) + assert message["author"]["id"] == webhook_id