diff --git a/gitea/basicGiteaApiObject.py b/gitea/basicGiteaApiObject.py index edc52f4..28f6877 100644 --- a/gitea/basicGiteaApiObject.py +++ b/gitea/basicGiteaApiObject.py @@ -23,8 +23,6 @@ class BasicGiteaApiObject: fields_to_parsers = {} def commit(self): - """ TODO: evaluate if there is a generalizable version of this method - """ raise NotImplemented() def get_dirty_fields(self): diff --git a/gitea/gitea.py b/gitea/gitea.py index 1843aa7..22ccda8 100644 --- a/gitea/gitea.py +++ b/gitea/gitea.py @@ -109,7 +109,7 @@ class User(GiteaApiObject): USER_MAIL = """/user/emails?sudo=%s""" # USER_PATCH = """/admin/users/%s""" # ADMIN_DELETE_USER = """/admin/users/%s""" # - ADMIN_EDIT_USER = """/admin/users/{name}""" # + ADMIN_EDIT_USER = """/admin/users/{username}""" # USER_HEATMAP = """/users/%s/heatmap""" # def __init__(self, gitea, id: int): @@ -147,9 +147,9 @@ class User(GiteaApiObject): def commit(self): values = self.get_dirty_fields() values.update( - {"email": self.email} - ) # this request must always contain the email for identifying users - args = {"name": self.username, "email": self.email} + {"source_id": self.source_id, "login_name": self.username} + ) # this request must always contain both, the user name and the _login source_ (e.g. ``None`` for local) + args = {"username": self.username} self.gitea.requests_patch(User.ADMIN_EDIT_USER.format(**args), data=values) self.dirty_fields = {} diff --git a/tests/test_api.py b/tests/test_api.py index 7ab1294..01f191a 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -60,15 +60,19 @@ def test_create_user(instance): assert email in user.emails assert user.email == email assert not user.is_admin + assert type(user.id) is int + assert user.is_admin is False def test_change_user(instance): user = instance.get_user_by_name(test_user) - user.website = "other_testname" - user.full_name = "other_description" + new_website = "http://testwebsite.de" + user.website = new_website + new_fullname = "Other Test Full Name" + user.full_name = new_fullname user.commit() del(user) user = instance.get_user_by_name(test_user) - assert user.full_name == "other_description" + assert user.full_name == new_fullname def test_create_org(instance):