diff options
author | 2019-11-11 17:48:42 +0100 | |
---|---|---|
committer | 2019-11-11 17:48:42 +0100 | |
commit | 3e01ca7c15aa50683b9d91e427bd8a42a7516ad7 (patch) | |
tree | f75cc13605dfff225b5b58d3f93601a8d7367cd2 | |
parent | Make sure the API return the appropriate response. (diff) |
Add tests to make sure the view return 405 for PATCH and PUT requests
-rw-r--r-- | pydis_site/apps/api/tests/test_offensive_message.py | 22 |
1 files changed, 22 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 dd9aaf21..0c3ba4f6 100644 --- a/pydis_site/apps/api/tests/test_offensive_message.py +++ b/pydis_site/apps/api/tests/test_offensive_message.py @@ -68,3 +68,25 @@ class CreationTests(APISubdomainTestCase): self.assertEqual(response.json(), { 'channel_id': ['Ensure this value is greater than or equal to 0.'] }) + + +class NotAllowedMethodsTests(APISubdomainTestCase): + @classmethod + def setUpTestData(cls): # noqa + delete_at = datetime.datetime.now() + datetime.timedelta(days=1) + + cls.valid_offensive_message = OffensiveMessage.objects.create( + id=602951077675139072, + channel_id=291284109232308226, + delete_date=delete_at.isoformat()[:-1] + ) + + def test_returns_405_for_patch_and_put_requests(self): + url = reverse( + 'bot:offensivemessage-detail', host='api', args=(self.valid_offensive_message.id,) + ) + + response = self.client.patch(url, {}) + self.assertEqual(response.status_code, 405) + response = self.client.put(url, {}) + self.assertEqual(response.status_code, 405) |