Merge pull request #19 from oyvindkolbu/update-team

Update Team class with new patchable fields, commit method and fixed the request method
pull/22/head
Langenfeld 2023-02-02 14:43:34 +01:00 zatwierdzone przez GitHub
commit 37f40229a3
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
3 zmienionych plików z 42 dodań i 4 usunięć

Wyświetl plik

@ -784,11 +784,25 @@ class Team(ApiObject):
"organization": lambda gitea, o: Organization.parse_response(gitea, o)
}
_patchable_fields = {
"can_create_org_repo",
"description",
"includes_all_repositories",
"name",
"permission",
"units",
"units_map",
}
@classmethod
def request(cls, gitea: 'Gitea', organization: str, team: str):
def request(cls, gitea: "Gitea", id: int):
return cls._request(gitea, {"id": id})
_patchable_fields = {"description", "name", "permission", "units"}
def commit(self):
values = self.get_dirty_fields()
args = {"id": self.id}
self.gitea.requests_patch(self.API_OBJECT.format(**args), data=values)
self.dirty_fields = {}
def add_user(self, user: User):
"""https://try.gitea.io/api/swagger#/organization/orgAddTeamMember"""

Wyświetl plik

@ -214,6 +214,30 @@ def test_create_team(instance):
assert team.description == "descr"
assert team.organization == org
def test_patch_team(instance):
fields = {
"can_create_org_repo": True,
"description": "patched description",
"includes_all_repositories": True,
"name": "newname",
"permission": "write",
}
org = Organization.request(instance, test_org)
team = instance.create_team(org, test_team[:1], "descr")
for field, value in fields.items():
setattr(team, field, value)
team.commit()
team = Team.request(instance, team.id)
for field, value in fields.items():
assert getattr(team, field) == value
def test_request_team(instance):
org = Organization.request(instance, test_org)
team = org.get_team(test_team)
team2 = Team.request(instance, team.id)
assert team.name == team2.name
def test_create_milestone(instance):
org = Organization.request(instance, test_org)
repo = org.get_repository(test_repo)

Wyświetl plik

@ -43,6 +43,6 @@ def test_list_issue(instance):
org = Organization.request(instance, test_org)
repo = instance.create_repo(org, test_repo, "Testing a huge number of Issues and how they are listed")
for x in range(0, 100):
Issue.create_issue(instance, repo, "TestIssue" + str(x), "We will be to many to be listed on one page")
Issue.create_issue(instance, repo, "TestIssue" + str(x), "We will be too many to be listed on one page")
issues = repo.get_issues()
assert len(issues) > 98
assert len(issues) > 98