Skip to content
This repository has been archived by the owner on Feb 27, 2023. It is now read-only.

Commit

Permalink
#5 Unlink package
Browse files Browse the repository at this point in the history
Signed-off-by: Uilian Ries <uilianries@gmail.com>
  • Loading branch information
uilianries committed Jul 13, 2019
1 parent 70eb55c commit a703b53
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
19 changes: 19 additions & 0 deletions bintray/bintray.py
Original file line number Diff line number Diff line change
Expand Up @@ -851,3 +851,22 @@ def link_package(self, subject, repo, source_subject, source_repo, source_packag
response = self._requester.put(url, json=json_data)
self._logger.info("Link package successfully")
return response

def unlink_package(self, subject, repo, source_subject, source_repo, source_package):
""" Unlink the package source_package from the repo repository.
Caller must be an admin of the organization owning the repository.
:param subject: target subject name
:param repo: target subject repository
:param source_subject: source subject
:param source_repo: source repository
:param source_package: source package name
:return: request response
"""
url = "{}/repository/{}/{}/links/{}/{}/{}".format(Bintray.BINTRAY_URL, subject, repo,
source_subject, source_repo,
source_package)
response = self._requester.delete(url)
self._logger.info("Unlink package successfully")
return response
12 changes: 12 additions & 0 deletions tests/test_repositories.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,15 @@ def test_link_package():
assert "Could not PUT (403): 403 Client Error: Forbidden for url: " \
"https://api.bintray.com/repository/uilianries/statistics/links/" \
"uilianries/generic/statistics" == error_message


def test_unlink_package():
bintray = Bintray()
error_message = ""
try:
bintray.unlink_package("uilianries", "statistics", "uilianries", "generic", "statistics")
except Exception as error:
error_message = str(error)
assert "Could not DELETE (404): 404 Client Error: Not Found for url: " \
"https://api.bintray.com/repository/uilianries/statistics/links/" \
"uilianries/generic/statistics" == error_message

0 comments on commit a703b53

Please sign in to comment.