mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-22 23:46:44 -06:00
Following code review
* Move test on UserTest class * Call `super().update()` in overriding `update` method
This commit is contained in:
parent
220e90e32e
commit
749e86fe91
@ -60,7 +60,7 @@ class UserSerializer(ValidatedModelSerializer):
|
||||
if password is not None:
|
||||
instance.set_password(password)
|
||||
|
||||
instance.save()
|
||||
super().update(instance, validated_data)
|
||||
|
||||
return instance
|
||||
|
||||
|
@ -54,24 +54,25 @@ class UserTest(APIViewTestCases.APIViewTestCase):
|
||||
)
|
||||
User.objects.bulk_create(users)
|
||||
|
||||
|
||||
class ChangeUserPasswordTest(APITestCase):
|
||||
|
||||
user_permissions = ['auth.change_user']
|
||||
|
||||
def test_that_password_is_changed(self):
|
||||
"""
|
||||
Test that password is changed
|
||||
"""
|
||||
|
||||
obj_perm = ObjectPermission(
|
||||
name='Test permission',
|
||||
actions=['change']
|
||||
)
|
||||
obj_perm.save()
|
||||
obj_perm.users.add(self.user)
|
||||
obj_perm.object_types.add(ContentType.objects.get_for_model(self.model))
|
||||
|
||||
user_credentials = {
|
||||
'username': 'user1',
|
||||
'password': 'abc123',
|
||||
}
|
||||
user = User.objects.create_user(**user_credentials)
|
||||
|
||||
print(user.id)
|
||||
|
||||
data = {
|
||||
'password': 'newpassword'
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user