kopia lustrzana https://github.com/Langenfeld/py-gitea
small fix to get team setup working again
rodzic
f8159771ef
commit
2720950c25
|
@ -30,7 +30,7 @@ class GiteaApiObject:
|
|||
fields_to_parsers = {}
|
||||
|
||||
@classmethod
|
||||
def request(cls, gitea, id):
|
||||
def get(cls, gitea, id):
|
||||
"""Use for ginving a nice e.g. 'request(gita, orgname, repo, ticket)'.
|
||||
All args are put into an args tuple for passing around"""
|
||||
return cls._request(gitea, {"id":id})
|
||||
|
@ -81,7 +81,7 @@ class Organization(GiteaApiObject):
|
|||
super(Organization, self).__init__(gitea, id=id)
|
||||
|
||||
@classmethod
|
||||
def request(cls, gitea, name):
|
||||
def get(cls, gitea, name):
|
||||
return cls._request(gitea, {"name": name})
|
||||
|
||||
# oldstuff
|
||||
|
@ -165,7 +165,7 @@ class User(GiteaApiObject):
|
|||
super(User, self).__init__(gitea, id=id)
|
||||
|
||||
@classmethod
|
||||
def request(cls, gitea, name):
|
||||
def get(cls, gitea, name):
|
||||
return cls._request(gitea, {"name": name})
|
||||
|
||||
|
||||
|
@ -246,7 +246,7 @@ class Repository(GiteaApiObject):
|
|||
}
|
||||
|
||||
@classmethod
|
||||
def request(cls, gitea, owner, name):
|
||||
def get(cls, gitea, owner, name):
|
||||
return cls._request(gitea, {"owner": owner, "name": name})
|
||||
|
||||
def get_branches(self):
|
||||
|
@ -343,7 +343,7 @@ class Milestone(GiteaApiObject):
|
|||
}
|
||||
|
||||
@classmethod
|
||||
def request(cls, gitea, owner, repo, number):
|
||||
def get(cls, gitea, owner, repo, number):
|
||||
return cls._request(gitea, {"owner":owner, "repo":repo, "number":number})
|
||||
|
||||
def full_print(self):
|
||||
|
@ -370,7 +370,7 @@ class Issue(GiteaApiObject):
|
|||
}
|
||||
|
||||
@classmethod
|
||||
def request(cls, gitea, owner, repo, number):
|
||||
def get(cls, gitea, owner, repo, number):
|
||||
api_object = cls._request(gitea, {"owner":owner, "repo":repo, "number":number})
|
||||
return api_object
|
||||
|
||||
|
@ -403,7 +403,7 @@ class Branch(GiteaApiObject):
|
|||
super(Branch, self).__init__(gitea, id=id)
|
||||
|
||||
@classmethod
|
||||
def request(cls, gitea, owner, repo, ref):
|
||||
def get(cls, gitea, owner, repo, ref):
|
||||
return cls._request(gitea, {"owner":owner, "repo":repo, "ref":ref})
|
||||
|
||||
|
||||
|
@ -424,7 +424,7 @@ class Team(GiteaApiObject):
|
|||
}
|
||||
|
||||
@classmethod
|
||||
def request(cls, gitea, id):
|
||||
def get(cls, gitea, id):
|
||||
return cls._request(gitea, {"id":id})
|
||||
|
||||
def add(self, toAdd):
|
||||
|
@ -501,6 +501,7 @@ class Util:
|
|||
time[:-3] + "00", "%Y-%m-%dT%H:%M:%S%z"
|
||||
)
|
||||
|
||||
|
||||
class Gitea:
|
||||
""" Has Gitea-authenticated session. Can Create Users/Organizations/Teams/...
|
||||
|
||||
|
@ -997,4 +998,6 @@ class Gitea:
|
|||
logging.error("Team not created... (gitea: %s)" % result["message"])
|
||||
logging.error(result["message"])
|
||||
raise Exception("Team not created... (gitea: %s)" % result["message"])
|
||||
return Team.parse_request(self, result)
|
||||
api_object = Team.parse_request(self, result)
|
||||
api_object.organization = org #fixes strange behaviour of gitea not returning a valid organization here.
|
||||
return api_object
|
||||
|
|
40
test_api.py
40
test_api.py
|
@ -32,19 +32,19 @@ def test_token_owner():
|
|||
assert gitea.get_user().username == "test", "Token user not 'test'."
|
||||
|
||||
def test_gitea_version():
|
||||
assert gitea.get_version() == "1.8.0", "Version changed. Updated?"
|
||||
assert gitea.get_version() == "1.8.2", "Version changed. Updated?"
|
||||
|
||||
def test_fail_get_non_existent_user():
|
||||
with pytest.raises(NotFoundException) as e:
|
||||
User.request(gitea, test_user)
|
||||
User.get(gitea, test_user)
|
||||
|
||||
def test_fail_get_non_existent_org():
|
||||
with pytest.raises(NotFoundException) as e:
|
||||
Organization.request(gitea, test_org)
|
||||
Organization.get(gitea, test_org)
|
||||
|
||||
def test_fail_get_non_existent_repo():
|
||||
with pytest.raises(NotFoundException) as e:
|
||||
Repository.request(gitea, test_user, test_repo)
|
||||
Repository.get(gitea, test_user, test_repo)
|
||||
|
||||
def test_create_user():
|
||||
email = test_user + "@example.org"
|
||||
|
@ -66,7 +66,7 @@ def test_create_org():
|
|||
assert not org.full_name
|
||||
|
||||
def test_create_repo_userowned():
|
||||
org = User.request(gitea, test_user)
|
||||
org = User.get(gitea, test_user)
|
||||
repo = gitea.create_repo(org, test_repo, "user owned repo")
|
||||
assert repo.description == "user owned repo"
|
||||
assert repo.owner == org
|
||||
|
@ -74,7 +74,7 @@ def test_create_repo_userowned():
|
|||
assert not repo.private
|
||||
|
||||
def test_create_repo_orgowned():
|
||||
org = Organization.request(gitea, test_org)
|
||||
org = Organization.get(gitea, test_org)
|
||||
repo = gitea.create_repo(org, test_repo, "descr")
|
||||
assert repo.description == "descr"
|
||||
assert repo.owner == org
|
||||
|
@ -82,41 +82,41 @@ def test_create_repo_orgowned():
|
|||
assert not repo.private
|
||||
|
||||
def test_create_team():
|
||||
org = Organization.request(gitea, test_org)
|
||||
org = Organization.get(gitea, "AlreadyPresentOrg")
|
||||
team = gitea.create_team(org, test_team, "descr")
|
||||
assert team.name == test_team
|
||||
assert team.description == "descr"
|
||||
assert team.organization == org
|
||||
|
||||
def test_delete_repo_userowned():
|
||||
org = User.request(gitea, test_user)
|
||||
repo = Repository.request(gitea, org.username, test_repo)
|
||||
org = User.get(gitea, test_user)
|
||||
repo = Repository.get(gitea, org.username, test_repo)
|
||||
repo.delete()
|
||||
with pytest.raises(NotFoundException) as e:
|
||||
Repository.request(gitea, test_user, test_repo)
|
||||
Repository.get(gitea, test_user, test_repo)
|
||||
|
||||
def test_delete_repo_orgowned():
|
||||
org = Organization.request(gitea, test_org)
|
||||
repo = Repository.request(gitea, org.username, test_repo)
|
||||
org = Organization.get(gitea, test_org)
|
||||
repo = Repository.get(gitea, org.username, test_repo)
|
||||
repo.delete()
|
||||
with pytest.raises(NotFoundException) as e:
|
||||
Repository.request(gitea, test_user, test_repo)
|
||||
Repository.get(gitea, test_user, test_repo)
|
||||
|
||||
def test_delete_team():
|
||||
org = Organization.request(gitea, test_org)
|
||||
team = Team.request(org, test_team)
|
||||
org = Organization.get(gitea, "AlreadyPresentOrg")
|
||||
team = Team.get(org, test_team)
|
||||
team.delete()
|
||||
with pytest.raises(NotFoundException) as e:
|
||||
Team(org, test_team)
|
||||
Team.get(org, test_team)
|
||||
|
||||
def test_delete_org():
|
||||
org = Organization.request(gitea, test_org)
|
||||
org = Organization.get(gitea, test_org)
|
||||
org.delete()
|
||||
with pytest.raises(NotFoundException) as e:
|
||||
Organization.request(gitea, test_org)
|
||||
Organization.get(gitea, test_org)
|
||||
|
||||
def test_delete_user():
|
||||
user = User.request(gitea, test_user)
|
||||
user = User.get(gitea, test_user)
|
||||
user.delete()
|
||||
with pytest.raises(NotFoundException) as e:
|
||||
User.request(gitea, test_user)
|
||||
User.get(gitea, test_user)
|
Ładowanie…
Reference in New Issue