Skip to content

WIP: fix(backend-test): the validation should not return None #669

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
9 changes: 7 additions & 2 deletions backend/timed/projects/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from django.db.models import Q, Sum
from django.utils.duration import duration_string
from rest_framework import exceptions
from rest_framework_json_api.relations import ResourceRelatedField
from rest_framework_json_api.serializers import ModelSerializer, ValidationError

Expand Down Expand Up @@ -183,7 +184,10 @@ def validate(self, data):
.exists()
):
return data
return None # pragma: no cover
msg = (
"You don't have the permission to update this task" # pragma: no cover
)
raise exceptions.ValidationError(msg) # pragma: no cover
# check if user is manager when creating a task
if (
user.is_superuser
Expand All @@ -201,7 +205,8 @@ def validate(self, data):
.exists()
):
return data
return None # pragma: no cover
msg = "You don't have the permission to create this task" # pragma: no cover
raise exceptions.ValidationError(msg) # pragma: no cover

class Meta:
"""Meta information for the task serializer."""
Expand Down