diff --git a/backend/accounts/tests.py b/backend/accounts/tests.py index 749d140..3d39360 100644 --- a/backend/accounts/tests.py +++ b/backend/accounts/tests.py @@ -83,7 +83,7 @@ def testRetrieveLoggedInAccountView_userLoggedIn_returnsAccountDetails(api_clien @pytest.mark.django_db -def testRetrieveLoggedInAccountView_userNotLoggedIn_returnsForbidden(): +def testRetrieveLoggedInAccountView_userNotLoggedIn_returnsUnauthorized(): # Arrange client = APIClient() @@ -91,7 +91,7 @@ def testRetrieveLoggedInAccountView_userNotLoggedIn_returnsForbidden(): response = client.get('/api/accounts/me/', format='json') # Assert - assert response.status_code == status.HTTP_403_FORBIDDEN + assert response.status_code == status.HTTP_401_UNAUTHORIZED @pytest.mark.django_db @@ -111,7 +111,7 @@ def testUpdateLogInAccountView_userLoggedIn_updateSuccesful(api_client, field): @pytest.mark.django_db -def testUpdateLogInAccountView_userNotLoggedIn_returnsForbidden(): +def testUpdateLogInAccountView_userNotLoggedIn_returnsUnauthorized(): # Arrange client = APIClient() @@ -119,4 +119,4 @@ def testUpdateLogInAccountView_userNotLoggedIn_returnsForbidden(): response = client.put('/api/accounts/me/', {}, format='json') # Assert - assert response.status_code == status.HTTP_403_FORBIDDEN + assert response.status_code == status.HTTP_401_UNAUTHORIZED diff --git a/backend/core/settings/base.py b/backend/core/settings/base.py index 9584d58..d4ba6c0 100644 --- a/backend/core/settings/base.py +++ b/backend/core/settings/base.py @@ -51,9 +51,6 @@ REST_FRAMEWORK = { # Use Django's standard `django.contrib.auth` permissions, # or allow read-only access for unauthenticated users. - 'DEFAULT_PERMISSION_CLASSES': [ - 'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly' - ], 'DEFAULT_AUTHENTICATION_CLASSES': ( 'rest_framework_simplejwt.authentication.JWTAuthentication', ) @@ -137,6 +134,5 @@ DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' -REST_FRAMEWORK = {} MEDIA_URL = '/media/' MEDIA_ROOT = os.path.join(BASE_DIR, 'media') diff --git a/backend/events/tests.py b/backend/events/tests.py index 086627a..1ded82d 100644 --- a/backend/events/tests.py +++ b/backend/events/tests.py @@ -101,7 +101,7 @@ def testEventCreation_withValidDetails_byUnauthenticatedUser_shouldNotCreateEven response = unauthenticated_client.post('/api/events/', event_data_copy, format='json') # Assert - assert response.status_code == status.HTTP_403_FORBIDDEN + assert response.status_code == status.HTTP_401_UNAUTHORIZED assert Event.objects.count() == 0 @@ -188,7 +188,7 @@ def testEventUpdate_withValidEventId_byOwner_shouldUpdateEvent( assert response.data['title'] == 'updated title' assert response.data['date'] == '2021-01-02' assert Event.objects.get().title == 'updated title' - assert Event.objects.get().date == '2021-01-02' + assert Event.objects.get().date.strftime('%Y-%m-%d') == '2021-01-02' @pytest.mark.django_db