feat: added deleting topics from repositories

pull/32/head^2
Langenfeld 2024-08-22 16:06:36 +02:00
rodzic 3910c2638a
commit 5b4650734c
2 zmienionych plików z 26 dodań i 7 usunięć

Wyświetl plik

@ -433,7 +433,7 @@ class Repository(ApiObject):
try: try:
results = self.gitea.requests_get_paginated( results = self.gitea.requests_get_paginated(
Repository.REPO_COMMITS % (self.owner.username, self.name), Repository.REPO_COMMITS % (self.owner.username, self.name),
page_limit= page_limit page_limit=page_limit,
) )
except ConflictException as err: except ConflictException as err:
logging.warning(err) logging.warning(err)
@ -466,7 +466,7 @@ class Repository(ApiObject):
) )
return results return results
def get_topics(self): def get_topics(self) -> list[str]:
results = self.gitea.requests_get( results = self.gitea.requests_get(
Repository.REPO_TOPICS % (self.owner.username, self.name) Repository.REPO_TOPICS % (self.owner.username, self.name)
) )
@ -474,7 +474,13 @@ class Repository(ApiObject):
def add_topic(self, topic: str): def add_topic(self, topic: str):
"""Add a topic to the repository""" """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) Repository.REPO_TOPIC % (self.owner.username, self.name, topic)
) )

Wyświetl plik

@ -348,6 +348,19 @@ def test_team_get_org(instance):
assert org.username == teams[0].organization.name 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): def test_delete_repo_userowned(instance):
user = User.request(instance, test_user) user = User.request(instance, test_user)
repo = Repository.request(instance, user.username, test_repo) repo = Repository.request(instance, user.username, test_repo)