add: block unit test

This commit is contained in:
starnakin 2024-04-09 13:26:20 +02:00
parent fd3e807136
commit 84833d5c9f

View File

@ -24,3 +24,23 @@ class BlockTest(TestCase):
response = self.client.get('/api/profiles/block')
self.assertListEqual(response.json(), [ProfileSerializer(blocked_profile).data])
def test_yourself(self):
self.client.login(username=self.blocker.username, password=self.blocker_password)
response: HttpResponse = self.client.post(f'/api/profiles/block/{self.blocker.pk}')
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
response = self.client.get('/api/profiles/block')
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertListEqual(response.json(), [])
def test_user_not_found(self):
self.client.login(username=self.blocker.username, password=self.blocker_password)
response: HttpResponse = self.client.post(f'/api/profiles/block/23')
self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)
response = self.client.get('/api/profiles/block')
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertListEqual(response.json(), [])