Browse Source

Fix: Fix test failure caused http error code(from 403 to 401)

pull/323/head
winkidney 2 years ago
parent
commit
69667006d8
3 changed files with 6 additions and 4 deletions
  1. +4
    -3
      core/tests/api.py
  2. +1
    -0
      pinry/settings/base.py
  3. +1
    -1
      users/tests.py

+ 4
- 3
core/tests/api.py View File

@@ -32,7 +32,7 @@ class ImageTests(APITestCase):
data=data,
format='json',
)
self.assertEqual(response.status_code, 403, response.data)
self.assertEqual(response.status_code, 401, response.data)


class BoardPrivacyTests(APITestCase):
@@ -220,7 +220,7 @@ class PinTests(APITestCase):
self.client.logout()
uri = reverse("pin-detail", kwargs={"pk": pin.pk})
response = self.client.patch(uri, format='json', data={})
self.assertEqual(response.status_code, 403)
self.assertEqual(response.status_code, 401, response.data)

def test_patch_detail(self):
image = create_image()
@@ -240,7 +240,8 @@ class PinTests(APITestCase):
pin = create_pin(self.user, image, [])
uri = reverse("pin-detail", kwargs={"pk": pin.pk})
self.client.logout()
self.assertEqual(self.client.delete(uri).status_code, 403)
resp = self.client.delete(uri)
self.assertEqual(resp.status_code, 401, resp.data)

def test_delete_detail(self):
image = create_image()


+ 1
- 0
pinry/settings/base.py View File

@@ -165,6 +165,7 @@ REST_FRAMEWORK = {
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination',
'PAGE_SIZE': API_LIMIT_PER_PAGE,
'DEFAULT_AUTHENTICATION_CLASSES': [
'rest_framework.authentication.BasicAuthentication',
'rest_framework.authentication.TokenAuthentication',
'rest_framework.authentication.SessionAuthentication',
]


+ 1
- 1
users/tests.py View File

@@ -61,7 +61,7 @@ class CreateUserTest(TestCase):
reverse('users:user-list'),
data=data,
)
self.assertEqual(response.status_code, 403)
self.assertEqual(response.status_code, 401)


class LogoutViewTest(TestCase):


Loading…
Cancel
Save