Skip to content

Commit 51ba25e

Browse files
authored
Merge pull request #9 from moremoban/dev
release 0.0.7
2 parents 9d3de28 + dbce75f commit 51ba25e

File tree

9 files changed

+41
-13
lines changed

9 files changed

+41
-13
lines changed

CHANGELOG.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
Change log
22
================================================================================
33

4+
0.0.7 - 28.08.2020
5+
--------------------------------------------------------------------------------
6+
7+
**Updated**
8+
9+
#. raise UrlNotFound when request a non-existent url
10+
411
0.0.6 - 26.08.2020
512
--------------------------------------------------------------------------------
613

changelog.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
name: gease
22
organisation: moremoban
33
releases:
4+
- changes:
5+
- action: Updated
6+
details:
7+
- "raise UrlNotFound when request a non-existent url"
8+
date: 28.08.2020
9+
version: 0.0.7
410
- changes:
511
- action: Updated
612
details:

gease.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ organisation: "moremoban"
44
author: "C. W."
55
contact: "wangc_2011@hotmail.com"
66
company: "Onni Software Ltd."
7-
version: "0.0.6"
8-
current_version: 0.0.6
9-
release: "0.0.6"
7+
version: "0.0.7"
8+
current_version: 0.0.7
9+
release: "0.0.7"
1010
copyright_year: 2017-2020
1111
command_line_interface: gease
1212
entry_point: "gease.main:main"

gease/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
__version__ = '0.0.6'
1+
__version__ = '0.0.7'
22
__author__ = 'C. W.'
33
__description__ = 'simply makes a git release using github api v3'

gease/exceptions.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,7 @@ class AbnormalGithubResponse(Exception):
2020

2121
class UnhandledException(Exception):
2222
pass
23+
24+
25+
class UrlNotFound(Exception):
26+
pass

gease/rest.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ def create(self, url, data):
5454

5555
def get(self, url):
5656
r = self.__session.get(url)
57-
return r.json()
57+
if r.status_code == 200:
58+
return r.json()
59+
elif r.status_code == 404:
60+
raise exceptions.UrlNotFound(f"{url} does not exist")
5861

5962
@classmethod
6063
def get_api(cls):
@@ -63,7 +66,6 @@ def get_api(cls):
6366
cls.__instance = cls(token)
6467
return cls.__instance
6568

66-
6769
@classmethod
6870
def get_public_api(cls):
6971
cls.__instance = cls(None)

setup.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
NAME = "gease"
3434
AUTHOR = "C. W."
35-
VERSION = "0.0.6"
35+
VERSION = "0.0.7"
3636
EMAIL = "wangc_2011@hotmail.com"
3737
LICENSE = "MIT"
3838
ENTRY_POINTS = {
@@ -45,7 +45,7 @@
4545
"simply makes a git release using github api v3"
4646
)
4747
URL = "https://github.com/moremoban/gease"
48-
DOWNLOAD_URL = "%s/archive/0.0.6.tar.gz" % URL
48+
DOWNLOAD_URL = "%s/archive/0.0.7.tar.gz" % URL
4949
FILES = ["README.rst", "CHANGELOG.rst"]
5050
KEYWORDS = [
5151
"python",
@@ -78,8 +78,8 @@
7878
}
7979
# You do not need to read beyond this line
8080
PUBLISH_COMMAND = "{0} setup.py sdist bdist_wheel upload -r pypi".format(sys.executable)
81-
GS_COMMAND = ("gs gease v0.0.6 " +
82-
"Find 0.0.6 in changelog for more details")
81+
GS_COMMAND = ("gs gease v0.0.7 " +
82+
"Find 0.0.7 in changelog for more details")
8383
NO_GS_MESSAGE = ("Automatic github release is disabled. " +
8484
"Please install gease to enable it.")
8585
UPLOAD_FAILED_MSG = (

tests/test_api.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
from gease.rest import Api
55
from gease.exceptions import (
6+
UrlNotFound,
67
RepoNotFoundError,
78
ReleaseExistException,
89
AbnormalGithubResponse,
@@ -90,3 +91,11 @@ def test_unknown_error(self):
9091
)
9192
api = Api("test")
9293
api.create("http://localhost/", "cool")
94+
95+
@raises(UrlNotFound)
96+
def test_get_unknown_url(self):
97+
self.fake_session.return_value = MagicMock(
98+
get=MagicMock(side_effect=UrlNotFound)
99+
)
100+
api = Api("test")
101+
api.get("s")

tests/test_contributors.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class TestPublish:
88
@patch("gease.contributors.Api.get_public_api")
99
def test_all_contributors(self, fake_api):
1010
sample_reply = [
11-
{"login": "howdy", "url": "https://api.github.com/users/howdy",}
11+
{"login": "howdy", "url": "https://api.github.com/users/howdy"}
1212
]
1313
fake_api.return_value = MagicMock(
1414
get=MagicMock(side_effect=[sample_reply, {"name": "hello world"}])
@@ -30,7 +30,7 @@ def test_all_contributors(self, fake_api):
3030
@patch("gease.contributors.Api.get_public_api")
3131
def test_no_names(self, fake_api):
3232
sample_reply = [
33-
{"login": "howdy", "url": "https://api.github.com/users/howdy",}
33+
{"login": "howdy", "url": "https://api.github.com/users/howdy"}
3434
]
3535
fake_api.return_value = MagicMock(
3636
get=MagicMock(side_effect=[sample_reply, {"name": None}])
@@ -41,5 +41,5 @@ def test_no_names(self, fake_api):
4141

4242
eq_(
4343
contributors,
44-
[{"name": "howdy", "url": "https://api.github.com/users/howdy",}],
44+
[{"name": "howdy", "url": "https://api.github.com/users/howdy"}],
4545
)

0 commit comments

Comments
 (0)