Skip to content

Commit

Permalink
fix: Wrap dicts everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
faucomte97 committed Sep 18, 2024
1 parent 7436ae9 commit 90df674
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion codeforlife/tests/model_view_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ def assert_serialized_model_equals_json_model(
model_serializer = model_view_set.get_serializer(model)

# Serialize the model.
serialized_model = model_serializer.data
serialized_model = dict(model_serializer.data)

# Recursively convert all datetimes to strings.
def datetime_values_to_representation(data: DataDict):
Expand Down
10 changes: 6 additions & 4 deletions codeforlife/views/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,9 @@ def bulk_create(self, request: Request[RequestUser]):
serializer.is_valid(raise_exception=True)
self.perform_bulk_create(serializer)
return Response(
serializer.data,
dict(serializer.data),
status=status.HTTP_201_CREATED,
headers=self.get_success_headers(serializer.data),
headers=self.get_success_headers(dict(serializer.data)),
)

def perform_bulk_create(
Expand Down Expand Up @@ -224,7 +224,7 @@ def bulk_partial_update(self, request: Request[RequestUser]):
)
serializer.is_valid(raise_exception=True)
self.perform_bulk_update(serializer)
return Response(serializer.data)
return Response(dict(serializer.data))

Check warning on line 227 in codeforlife/views/model.py

View check run for this annotation

Codecov / codecov/patch

codeforlife/views/model.py#L227

Added line #L227 was not covered by tests

def perform_bulk_update(
self, serializer: "ModelListSerializer[RequestUser, AnyModel]"
Expand Down Expand Up @@ -303,7 +303,9 @@ def update(
)
serializer.is_valid(raise_exception=True)
serializer.save()
return Response(**(response_kwargs or {}), data=serializer.data)
return Response(

Check warning on line 306 in codeforlife/views/model.py

View check run for this annotation

Codecov / codecov/patch

codeforlife/views/model.py#L306

Added line #L306 was not covered by tests
**(response_kwargs or {}), data=dict(serializer.data)
)

update.__name__ = name

Expand Down

0 comments on commit 90df674

Please sign in to comment.