aboutsummaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorGravatar Johannes Christ <[email protected]>2019-01-20 11:27:47 +0100
committerGravatar Johannes Christ <[email protected]>2019-01-20 11:27:47 +0100
commit14155c93d47be033acace93d469dfc1882797f96 (patch)
treee0b05c93779a94ee0e36e4f6be2055690efbda93 /api
parentDo not rely on hardcoded ID. (diff)
Add a test case for the message deletion endpoint.
Diffstat (limited to 'api')
-rw-r--r--api/tests/test_deleted_messages.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/api/tests/test_deleted_messages.py b/api/tests/test_deleted_messages.py
new file mode 100644
index 00000000..3a6b8e8e
--- /dev/null
+++ b/api/tests/test_deleted_messages.py
@@ -0,0 +1,43 @@
+from datetime import datetime
+
+from django_hosts.resolvers import reverse
+
+from ..models import User
+from .base import APISubdomainTestCase
+
+
+class DeletedMessagesTests(APISubdomainTestCase):
+ @classmethod
+ def setUpTestData(cls): # noqa
+ cls.author = User.objects.create(
+ id=55,
+ name='Robbie Rotten',
+ discriminator=55,
+ avatar_hash=None
+ )
+
+ cls.data = {
+ 'actor': None,
+ 'creation': datetime.utcnow().isoformat(),
+ 'deletedmessage_set': [
+ {
+ 'author': cls.author.id,
+ 'id': 55,
+ 'channel_id': 5555,
+ 'content': "Terror Billy is a meanie",
+ 'embeds': []
+ },
+ {
+ 'author': cls.author.id,
+ 'id': 56,
+ 'channel_id': 5555,
+ 'content': "If you purge this, you're evil",
+ 'embeds': []
+ }
+ ]
+ }
+
+ def test_accepts_valid_data(self):
+ url = reverse('bot:messagedeletioncontext-list', host='api')
+ response = self.client.post(url, data=self.data)
+ self.assertEqual(response.status_code, 201)