fixed listing user accessible repositories

pull/7/head
Langenfeld 2021-10-05 16:31:07 +02:00
rodzic 2645ff5c07
commit 5d1ed27c88
3 zmienionych plików z 13 dodań i 11 usunięć

Wyświetl plik

@ -170,6 +170,11 @@ class User(GiteaApiObject):
results = self.gitea.requests_get(url, sudo=self)
return [Team.parse_response(self.gitea, result) for result in results]
def get_accessible_repos(self) -> List['Repository']:
""" Get all Repositories accessible by the logged in User."""
results = self.gitea.requests_get("/user/repos", sudo=self)
return [Repository.parse_response(self, result) for result in results]
def __request_emails(self):
result = self.gitea.requests_get(User.USER_MAIL % self.login)
# report if the adress changed by this
@ -808,11 +813,6 @@ class Gitea:
path = "/repos/" + username + "/" + reponame + "/subscription"
return self.requests_get(path)
def get_accessible_repositories(self) -> List['Repository']:
""" Get all Repositories accessible by the logged in User."""
results = self.requests_get("/user/repos")
return [Repository.parse_response(self, result) for result in results]
def get_users_following(self, username):
path = "/users/" + username + "/following"
return self.requests_get(path)

Wyświetl plik

@ -5,7 +5,7 @@ with open('README.md') as readme_file:
setup_args = dict(
name='py-gitea',
version='0.1.4',
version='0.1.5',
description='A python wrapper for the Gitea API',
long_description_content_type="text/markdown",
long_description=README,

Wyświetl plik

@ -155,6 +155,11 @@ def test_user_teams(instance):
teams = user.get_teams()
assert team in teams
def test_get_accessible_repositories(instance):
user = instance.get_user_by_name(test_user)
repos = user.get_accessible_repos()
assert len(repos) > 0
def test_create_issue(instance):
org = Organization.request(instance, test_org)
repo = Repository.request(instance, org.username, test_repo)
@ -202,13 +207,10 @@ def test_delete_org(instance):
Organization.request(instance, test_org)
def test_delete_user(instance):
user = User.request(instance, test_user)
user.delete()
with pytest.raises(NotFoundException) as e:
User.request(instance, test_user)
def test_get_accessible_repositories(instance):
repos = instance.get_accessible_repositories()
assert repos == []