Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix rest settings #133

Merged
merged 2 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions backend/accounts/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,15 @@ def testRetrieveLoggedInAccountView_userLoggedIn_returnsAccountDetails(api_clien


@pytest.mark.django_db
def testRetrieveLoggedInAccountView_userNotLoggedIn_returnsForbidden():
def testRetrieveLoggedInAccountView_userNotLoggedIn_returnsUnauthorized():
# Arrange
client = APIClient()

# Act
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
Expand All @@ -111,12 +111,12 @@ def testUpdateLogInAccountView_userLoggedIn_updateSuccesful(api_client, field):


@pytest.mark.django_db
def testUpdateLogInAccountView_userNotLoggedIn_returnsForbidden():
def testUpdateLogInAccountView_userNotLoggedIn_returnsUnauthorized():
# Arrange
client = APIClient()

# Act
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
4 changes: 0 additions & 4 deletions backend/core/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
)
Expand Down Expand Up @@ -137,6 +134,5 @@

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

REST_FRAMEWORK = {}
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
4 changes: 2 additions & 2 deletions backend/events/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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
Expand Down
Loading