diff options
Diffstat (limited to 'pydis_site/apps')
| -rw-r--r-- | pydis_site/apps/api/tests/test_nominations.py | 32 | 
1 files changed, 32 insertions, 0 deletions
| diff --git a/pydis_site/apps/api/tests/test_nominations.py b/pydis_site/apps/api/tests/test_nominations.py index 62b2314c..b3742cdd 100644 --- a/pydis_site/apps/api/tests/test_nominations.py +++ b/pydis_site/apps/api/tests/test_nominations.py @@ -524,3 +524,35 @@ class NominationTests(AuthenticatedAPITestCase):          self.assertEqual(response.json(), {              'actor': ["The actor doesn't exist or has not nominated the user."]          }) + +    def test_patch_nomination_set_thread_id_of_active_nomination(self): +        url = reverse('api:bot:nomination-detail', args=(self.active_nomination.id,)) +        data = {'thread_id': 9876543210} +        response = self.client.patch(url, data=data) +        self.assertEqual(response.status_code, 200) + +    def test_patch_nomination_set_thread_id_and_reviewed_of_active_nomination(self): +        url = reverse('api:bot:nomination-detail', args=(self.active_nomination.id,)) +        data = {'thread_id': 9876543210, "reviewed": True} +        response = self.client.patch(url, data=data) +        self.assertEqual(response.status_code, 200) + +    def test_modifying_thread_id_when_ending_nomination(self): +        url = reverse('api:bot:nomination-detail', args=(self.active_nomination.id,)) +        data = {'thread_id': 9876543210, 'active': False, 'end_reason': "What?"} + +        response = self.client.patch(url, data=data) +        self.assertEqual(response.status_code, 400) +        self.assertEqual(response.json(), { +            'thread_id': ['This field cannot be set when ending a nomination.'] +        }) + +    def test_patch_thread_id_for_inactive_nomination(self): +        url = reverse('api:bot:nomination-detail', args=(self.inactive_nomination.id,)) +        data = {'thread_id': 9876543210} + +        response = self.client.patch(url, data=data) +        self.assertEqual(response.status_code, 400) +        self.assertEqual(response.json(), { +            'thread_id': ['This field cannot be set if the nomination is inactive.'] +        }) | 
