diff options
author | 2019-09-30 12:29:16 +0200 | |
---|---|---|
committer | 2019-09-30 12:29:16 +0200 | |
commit | 599f4b1523d76f600f19ae1b5f346d683e0183ce (patch) | |
tree | 99a76d6169c04468a5dd3194979bd2b64daf1a7f /pydis_site/apps/api/tests | |
parent | Correct the Dockerfile path for azure. (diff) | |
parent | Merge branch 'master' into decoupling-warnings-and-notes (diff) |
Merge pull request #261 from python-discord/decoupling-warnings-and-notes
Migrate hidden warnings to notes and add additional validation
Diffstat (limited to 'pydis_site/apps/api/tests')
-rw-r--r-- | pydis_site/apps/api/tests/test_infractions.py | 48 |
1 files changed, 34 insertions, 14 deletions
diff --git a/pydis_site/apps/api/tests/test_infractions.py b/pydis_site/apps/api/tests/test_infractions.py index 0092d355..c58c32e2 100644 --- a/pydis_site/apps/api/tests/test_infractions.py +++ b/pydis_site/apps/api/tests/test_infractions.py @@ -257,32 +257,52 @@ class CreationTests(APISubdomainTestCase): def test_returns_400_for_expiring_non_expirable_type(self): url = reverse('bot:infraction-list', host='api') - data = { - 'user': self.user.id, - 'actor': self.user.id, - 'type': 'kick', - 'expires_at': '5018-11-20T15:52:00+00:00' - } - response = self.client.post(url, data=data) - self.assertEqual(response.status_code, 400) - self.assertEqual(response.json(), { - 'expires_at': [f'{data["type"]} infractions cannot expire.'] - }) + for infraction_type in ('kick', 'warning'): + data = { + 'user': self.user.id, + 'actor': self.user.id, + 'type': infraction_type, + 'expires_at': '5018-11-20T15:52:00+00:00' + } + + response = self.client.post(url, data=data) + self.assertEqual(response.status_code, 400) + self.assertEqual(response.json(), { + 'expires_at': [f'{data["type"]} infractions cannot expire.'] + }) def test_returns_400_for_hidden_non_hideable_type(self): url = reverse('bot:infraction-list', host='api') + + for infraction_type in ('superstar', 'warning'): + data = { + 'user': self.user.id, + 'actor': self.user.id, + 'type': infraction_type, + 'hidden': True + } + + response = self.client.post(url, data=data) + self.assertEqual(response.status_code, 400) + self.assertEqual(response.json(), { + 'hidden': [f'{data["type"]} infractions cannot be hidden.'] + }) + + def test_returns_400_for_non_hidden_required_hidden_type(self): + url = reverse('bot:infraction-list', host='api') + data = { 'user': self.user.id, 'actor': self.user.id, - 'type': 'superstar', - 'hidden': True + 'type': 'note', + 'hidden': False, } response = self.client.post(url, data=data) self.assertEqual(response.status_code, 400) self.assertEqual(response.json(), { - 'hidden': [f'{data["type"]} infractions cannot be hidden.'] + 'hidden': [f'{data["type"]} infractions must be hidden.'] }) |