Skip to content

Commit

Permalink
Add tests for infraction deletion method
Browse files Browse the repository at this point in the history
  • Loading branch information
ks129 committed Dec 9, 2020
1 parent 9efd0cb commit f5ab88b
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions pydis_site/apps/api/tests/test_infractions.py
Expand Up @@ -512,6 +512,36 @@ def test_integrity_error_if_missing_active_field(self):
)


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):
Expand Down

0 comments on commit f5ab88b

Please sign in to comment.