kopia lustrzana https://github.com/Langenfeld/py-gitea
fixed creation and deletion of teams; added get_team(name) function to organization
rodzic
ee25377f0f
commit
76a1c50cdb
|
@ -152,6 +152,13 @@ class Organization(GiteaApiObject):
|
||||||
)
|
)
|
||||||
return [Team.parse_request(self.gitea, result) for result in results]
|
return [Team.parse_request(self.gitea, result) for result in results]
|
||||||
|
|
||||||
|
def get_team(self, name):
|
||||||
|
teams = self.get_teams()
|
||||||
|
for team in teams:
|
||||||
|
if team.name == name:
|
||||||
|
return team
|
||||||
|
raise NotFoundException("Team not existent in organization.")
|
||||||
|
|
||||||
def get_team_by_name(self, name):
|
def get_team_by_name(self, name):
|
||||||
teams = self.get_teams()
|
teams = self.get_teams()
|
||||||
for team in teams:
|
for team in teams:
|
||||||
|
@ -477,7 +484,7 @@ class Team(GiteaApiObject):
|
||||||
}
|
}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def request(cls, gitea, id):
|
def request(cls, gitea, organization, team):
|
||||||
return cls._request(gitea, {"id":id})
|
return cls._request(gitea, {"id":id})
|
||||||
|
|
||||||
patchable_fields = {"description", "name", "permission", "units"}
|
patchable_fields = {"description", "name", "permission", "units"}
|
||||||
|
@ -1056,5 +1063,5 @@ class Gitea:
|
||||||
logging.error(result["message"])
|
logging.error(result["message"])
|
||||||
raise Exception("Team not created... (gitea: %s)" % result["message"])
|
raise Exception("Team not created... (gitea: %s)" % result["message"])
|
||||||
api_object = 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.
|
setattr(api_object, "_organization", org) #fixes strange behaviour of gitea not returning a valid organization here.
|
||||||
return api_object
|
return api_object
|
||||||
|
|
|
@ -126,10 +126,10 @@ def test_delete_repo_orgowned():
|
||||||
|
|
||||||
def test_delete_team():
|
def test_delete_team():
|
||||||
org = Organization.request(gitea, "AlreadyPresentOrg")
|
org = Organization.request(gitea, "AlreadyPresentOrg")
|
||||||
team = Team.request(org, test_team)
|
team = org.get_team(test_team)
|
||||||
team.delete()
|
team.delete()
|
||||||
with pytest.raises(NotFoundException) as e:
|
with pytest.raises(NotFoundException) as e:
|
||||||
Team.request(org, test_team)
|
team = org.get_team(test_team)
|
||||||
|
|
||||||
def test_delete_org():
|
def test_delete_org():
|
||||||
org = Organization.request(gitea, test_org)
|
org = Organization.request(gitea, test_org)
|
||||||
|
|
Ładowanie…
Reference in New Issue