kopia lustrzana https://github.com/Langenfeld/py-gitea
feat: added deleting topics from repositories
rodzic
3910c2638a
commit
5b4650734c
|
@ -433,7 +433,7 @@ class Repository(ApiObject):
|
|||
try:
|
||||
results = self.gitea.requests_get_paginated(
|
||||
Repository.REPO_COMMITS % (self.owner.username, self.name),
|
||||
page_limit= page_limit
|
||||
page_limit=page_limit,
|
||||
)
|
||||
except ConflictException as err:
|
||||
logging.warning(err)
|
||||
|
@ -466,7 +466,7 @@ class Repository(ApiObject):
|
|||
)
|
||||
return results
|
||||
|
||||
def get_topics(self):
|
||||
def get_topics(self) -> list[str]:
|
||||
results = self.gitea.requests_get(
|
||||
Repository.REPO_TOPICS % (self.owner.username, self.name)
|
||||
)
|
||||
|
@ -474,7 +474,13 @@ class Repository(ApiObject):
|
|||
|
||||
def add_topic(self, topic: str):
|
||||
"""Add a topic to the repository"""
|
||||
result = self.gitea.requests_put(
|
||||
self.gitea.requests_put(
|
||||
Repository.REPO_TOPIC % (self.owner.username, self.name, topic)
|
||||
)
|
||||
|
||||
def del_topic(self, topic: str):
|
||||
"""Add a topic to the repository"""
|
||||
self.gitea.requests_delete(
|
||||
Repository.REPO_TOPIC % (self.owner.username, self.name, topic)
|
||||
)
|
||||
|
||||
|
|
|
@ -348,6 +348,19 @@ def test_team_get_org(instance):
|
|||
assert org.username == teams[0].organization.name
|
||||
|
||||
|
||||
def test_topic_functions(instance):
|
||||
user = User.request(instance, test_user)
|
||||
repo = Repository.request(instance, user.username, test_repo)
|
||||
repo.add_topic("rings")
|
||||
repo.add_topic("swords")
|
||||
repo.add_topic("dragons")
|
||||
assert "swords" in repo.get_topics()
|
||||
repo.del_topic("swords")
|
||||
assert "swords" not in repo.get_topics()
|
||||
assert "dragons" in repo.get_topics()
|
||||
assert "rings" in repo.get_topics()
|
||||
|
||||
|
||||
def test_delete_repo_userowned(instance):
|
||||
user = User.request(instance, test_user)
|
||||
repo = Repository.request(instance, user.username, test_repo)
|
||||
|
|
Ładowanie…
Reference in New Issue