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

Commit

Permalink
#13 Get release notes
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 20, 2019
1 parent 0bbd4d1 commit 8ba2c24
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 7 deletions.
30 changes: 30 additions & 0 deletions bintray/bintray.py
Original file line number Diff line number Diff line change
Expand Up @@ -2223,4 +2223,34 @@ def get_all_products_signed_eulas(self, subject, from_date=None, to_date=None, u
self._logger.info("Get successfully")
return response

# Release Notes

def get_package_release_notes(self, subject, repo, package):
""" Get the release notes for a specific package by subject; Either Bintray
release notes or GitHub release notes.
:param subject: repository owner
:param repo: repository name
:param package: package name
:return: returns the release notes for a specific package by subject
"""
url = "{}/packages/{}/{}/{}/release_notes".format(Bintray.BINTRAY_URL, subject, repo,
package)
response = self._requester.get(url)
self._logger.info("Get successfully")
return response

def create_package_release_notes(self):
pass

def delete_package_release_notes(self):
pass

def get_version_release_notes(self):
pass

def create_version_release_notes(self):
pass

def get_version_release_notes(self):
pass
7 changes: 6 additions & 1 deletion bintray/requester.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@ def _raise_error(self, message, response):
try:
response.raise_for_status()
except Exception as error:
raise Exception("{} ({}): {}".format(message, response.status_code, str(error)))
error_message = str(error)
try:
error_message = response.json()["message"]
except:
pass
raise Exception("{} ({}): {}".format(message, response.status_code, error_message))

def get(self, url, params=None):
""" Forward GET method
Expand Down
2 changes: 0 additions & 2 deletions tests/test_attributes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

import pytest
from bintray.bintray import Bintray

Expand Down
2 changes: 0 additions & 2 deletions tests/test_content_sync.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

from bintray.bintray import Bintray


Expand Down
14 changes: 14 additions & 0 deletions tests/test_release_notes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from bintray.bintray import Bintray


def test_get_package_release_notes():
bintray = Bintray()
error_message = ""
try:
bintray.get_package_release_notes("uilianries", "generic", "statistics")
except Exception as error:
error_message = str(error)
assert "Could not GET (400): No release notes found for subject 'uilianries' repo 'generic' " \
"and pkg 'statistics' in the package level. Please check the version level release " \
"notes" == error_message

2 changes: 0 additions & 2 deletions tests/test_upload_publishing.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

import tempfile

from bintray.bintray import Bintray
Expand Down

0 comments on commit 8ba2c24

Please sign in to comment.