-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test covering Update view without queryset attribute (#9528)
- Loading branch information
1 parent
61e3376
commit a59aa2d
Showing
1 changed file
with
14 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,3 +56,17 @@ def test_prefetch_related_excluding_instance_from_original_queryset(self): | |
'email': '[email protected]' | ||
} | ||
assert response.data == expected | ||
|
||
def test_can_update_without_queryset_on_class_view(self): | ||
class UserUpdateWithoutQuerySet(generics.UpdateAPIView): | ||
serializer_class = UserSerializer | ||
|
||
def get_object(self): | ||
return User.objects.get(pk=self.kwargs['pk']) | ||
|
||
request = factory.patch('/', {'username': 'new'}) | ||
response = UserUpdateWithoutQuerySet.as_view()(request, pk=self.user.pk) | ||
assert response.data['id'] == self.user.id | ||
assert response.data['username'] == 'new' | ||
self.user.refresh_from_db() | ||
assert self.user.username == 'new' |