aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Akarys42 <[email protected]>2019-11-11 18:01:55 +0100
committerGravatar Akarys42 <[email protected]>2019-11-11 18:01:55 +0100
commit20bfc996404ec9faee8c7105001540724a197dac (patch)
tree075228f11f49b6b113e76fa1947e9bfd745f21b5
parentAdd tests to make sure the view return 405 for PATCH and PUT requests (diff)
Add deletion tests
-rw-r--r--pydis_site/apps/api/tests/test_offensive_message.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/pydis_site/apps/api/tests/test_offensive_message.py b/pydis_site/apps/api/tests/test_offensive_message.py
index 0c3ba4f6..04da6d26 100644
--- a/pydis_site/apps/api/tests/test_offensive_message.py
+++ b/pydis_site/apps/api/tests/test_offensive_message.py
@@ -70,6 +70,30 @@ class CreationTests(APISubdomainTestCase):
})
+class DeletionTests(APISubdomainTestCase):
+ @classmethod
+ def setUpTestData(cls): # noqa
+ delete_at = datetime.datetime.now(tz=datetime.timezone.utc) + datetime.timedelta(days=1)
+
+ cls.valid_offensive_message = OffensiveMessage.objects.create(
+ id=602951077675139072,
+ channel_id=291284109232308226,
+ delete_date=delete_at.isoformat()
+ )
+
+ def test_delete_data(self):
+ url = reverse(
+ 'bot:offensivemessage-detail', host='api', args=(self.valid_offensive_message.id,)
+ )
+
+ response = self.client.delete(url)
+ self.assertEqual(response.status_code, 204)
+
+ url = reverse('bot:offensivemessage-list', host='api')
+ response = self.client.get(url)
+ self.assertNotIn(self.valid_offensive_message.id, response.json())
+
+
class NotAllowedMethodsTests(APISubdomainTestCase):
@classmethod
def setUpTestData(cls): # noqa