-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: get latest GTF release name from Github API
- Loading branch information
Showing
7 changed files
with
59 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import requests | ||
|
||
|
||
class GithubUtils: | ||
def get_latest_release_name(self, owner, repository): | ||
latest_release_api_url = f"https://api.github.com/repos/{owner}/{repository}/releases/latest" | ||
response = requests.get(latest_release_api_url) | ||
if response.status_code != 200: | ||
response.raise_for_status() | ||
return response.json()["name"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from unittest import TestCase | ||
|
||
import pytest | ||
|
||
from gdk.common.GithubUtils import GithubUtils | ||
|
||
|
||
class MockGetResponse: | ||
def __init__(self, json_data, status_code): | ||
self.json_data = json_data | ||
self.status_code = status_code | ||
|
||
def json(self): | ||
return self.json_data | ||
|
||
|
||
class GithubUtilsTest(TestCase): | ||
@pytest.fixture(autouse=True) | ||
def __inject_fixtures(self, mocker): | ||
self.mocker = mocker | ||
|
||
def test_GIVEN_latest_release_request_WHEN_request_successful_THEN_return_release_name(self): | ||
self.mocker.patch("requests.get", return_value=MockGetResponse({"name": "1.0.0"}, 200)) | ||
github_utils = GithubUtils() | ||
latest_release = github_utils.get_latest_release_name("author", "repo") | ||
assert latest_release == "1.0.0" |