diff options
author | 2020-12-13 23:32:24 -0500 | |
---|---|---|
committer | 2020-12-13 23:32:24 -0500 | |
commit | a4ba6221d252d28ccab161b377cf9bf299bdb25f (patch) | |
tree | 613f009014f660d2786dd786eedd64496403a801 /pydis_site/apps/api/tests | |
parent | Merge pull request #437 from python-discord/bugfix/lemon/snekbox-not-showing-... (diff) | |
parent | Merge branch 'master' into ks123/infractions/delete-method (diff) |
Merge pull request #432 from python-discord/ks123/infractions/delete-method
Include DestroyModelMixin to infractions view for DELETE method
Diffstat (limited to 'pydis_site/apps/api/tests')
-rw-r--r-- | pydis_site/apps/api/tests/test_infractions.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/pydis_site/apps/api/tests/test_infractions.py b/pydis_site/apps/api/tests/test_infractions.py index 93ef8171..82b497aa 100644 --- a/pydis_site/apps/api/tests/test_infractions.py +++ b/pydis_site/apps/api/tests/test_infractions.py @@ -512,6 +512,36 @@ class CreationTests(APISubdomainTestCase): ) +class InfractionDeletionTests(APISubdomainTestCase): + @classmethod + def setUpTestData(cls): + cls.user = User.objects.create( + id=9876, + name='Unknown user', + discriminator=9876, + ) + + cls.warning = Infraction.objects.create( + user_id=cls.user.id, + actor_id=cls.user.id, + type='warning', + active=False + ) + + def test_delete_unknown_infraction_returns_404(self): + url = reverse('bot:infraction-detail', args=('something',), host='api') + response = self.client.delete(url) + + self.assertEqual(response.status_code, 404) + + def test_delete_known_infraction_returns_204(self): + url = reverse('bot:infraction-detail', args=(self.warning.id,), host='api') + response = self.client.delete(url) + + self.assertEqual(response.status_code, 204) + self.assertRaises(Infraction.DoesNotExist, Infraction.objects.get, id=self.warning.id) + + class ExpandedTests(APISubdomainTestCase): @classmethod def setUpTestData(cls): |