kopia lustrzana https://github.com/Langenfeld/py-gitea
fix: require supplying login name and source id when updating users
rodzic
8a2a19739b
commit
79276e94d1
|
@ -150,11 +150,17 @@ class User(GiteaApiObject):
|
|||
"website",
|
||||
}
|
||||
|
||||
def commit(self):
|
||||
def commit(self, login_name: str, source_id: int = 0):
|
||||
"""
|
||||
Unfortunately it is necessary to require the login name
|
||||
as well as the login source (that is not supplied when getting a user) for
|
||||
changing a user.
|
||||
Usually source_id is 0 and the login_name is equal to the username.
|
||||
"""
|
||||
values = self.get_dirty_fields()
|
||||
values.update(
|
||||
# api-doc says that the "source_id" is necessary; works without though
|
||||
{"login_name": self.username}
|
||||
{"login_name": login_name, "source_id": source_id}
|
||||
)
|
||||
args = {"username": self.username}
|
||||
self.gitea.requests_patch(User.ADMIN_EDIT_USER.format(**args), data=values)
|
||||
|
|
|
@ -69,7 +69,7 @@ def test_change_user(instance):
|
|||
user.location = location
|
||||
new_fullname = "Other Test Full Name"
|
||||
user.full_name = new_fullname
|
||||
user.commit()
|
||||
user.commit(user.username, 0)
|
||||
del(user)
|
||||
user = instance.get_user_by_name(test_user)
|
||||
assert user.full_name == new_fullname
|
||||
|
|
Ładowanie…
Reference in New Issue