Skip to content

Commit b28b28f

Browse files
committed
Merge tag '0.1.1'
2 parents dd98572 + 37d280c commit b28b28f

File tree

5 files changed

+50
-7
lines changed

5 files changed

+50
-7
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@
33
.cache/
44
.tox/
55
__pycache__/
6+
build/
7+
dist/

.travis.yml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,23 @@ script:
88
- tox
99
- tox -e docs
1010
- '[[ "$TRAVIS_TAG" = "" ]] || [[ "$TRAVIS_TAG" = "$(python setup.py --version)" ]]'
11+
# Ensure changelog was written:
1112
- |
12-
if git show --format=%B --quiet "$TRAVIS_COMMIT_RANGE$TRAVIS_TAG" | grep '\[changelog skip\]' > /dev/null; then
13-
echo "Skip changelog checker..."
13+
if [[ "$TRAVIS_PULL_REQUEST" != "false" ]]; then
14+
curl -L http://github.com/micha/jsawk/raw/master/jsawk > /tmp/jsawk
15+
chmod +x /tmp/jsawk
16+
PR_BASE="$(curl -vf https://api.github.com/repos/$TRAVIS_REPO_SLUG/pulls/$TRAVIS_PULL_REQUEST.json \
17+
| jq --raw-output '.base.sha')"
18+
CHANGE_RANGE="${PR_BASE}..${TRAVIS_PULL_REQUEST_SHA}"
1419
elif [[ "$TRAVIS_TAG" != "" ]]; then
15-
! grep -i "to be released" README.rst
20+
CHANGE_RANGE="${TRAVIS_TAG}^1..${TRAVIS_TAG}"
21+
else
22+
CHANGE_RANGE="${TRAVIS_COMMIT_RANGE}"
23+
fi
24+
if git show --format=%B --quiet "$CHANGE_RANGE" \
25+
| grep '\[changelog skip\]' > /dev/null; then
26+
echo "Skip changelog checker..."
1627
else
17-
[[ "$(git diff --name-only "$TRAVIS_COMMIT_RANGE" | grep CHANGES\.rst)" != "" ]]
28+
git diff --name-only "$CHANGE_RANGE" | grep CHANGES.rst
1829
fi
30+
- '[[ "$TRAVIS_TAG" = "" ]] || ! grep -i "to be released" CHANGES.rst'

CHANGES.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ Version 0.2.0
77
To be released.
88

99

10+
Version 0.1.1
11+
-------------
12+
13+
Released on August 3, 2017.
14+
15+
- Fixed a bug that message of ``UnexpectedNirumResponseError`` was not a ``str``
16+
but ``unicode`` in Python 2.
17+
18+
1019
Version 0.1.0
1120
-------------
1221

nirum_http.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,7 @@ def call(self,
4545
try:
4646
content = response.json()
4747
except ValueError:
48-
raise UnexpectedNirumResponseError(response.text)
48+
raise UnexpectedNirumResponseError(
49+
response.content if isinstance('', bytes) else response.text
50+
)
4951
return response.ok, content

test.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
from pytest import fixture
1+
from pytest import fixture, raises
22
from requests import Session
33
from requests_mock import Adapter
44

5-
from nirum_http import HttpTransport
5+
from nirum_http import HttpTransport, UnexpectedNirumResponseError
66

77

88
@fixture
@@ -34,3 +34,21 @@ def callback(request, context):
3434
)
3535
assert successful
3636
assert result == {'_type': 'point', 'x': 1.0, 'top': 2.0}
37+
38+
39+
def test_unexpected_nirum_response_error(fx_adapter, fx_session):
40+
method_name = 'hello_world'
41+
base_url = 'http://example.com/'
42+
url = '{0}?method={1}'.format(base_url, method_name)
43+
fx_adapter.register_uri('POST', url, text='Error message')
44+
t = HttpTransport(base_url, session=fx_session)
45+
with raises(UnexpectedNirumResponseError) as exc_info:
46+
t.call(
47+
method_name, payload={'name': 'John'},
48+
service_annotations={},
49+
method_annotations={},
50+
parameter_annotations={}
51+
)
52+
exc = exc_info.value
53+
assert exc.args == ('Error message',)
54+
assert isinstance(exc.args[0], str)

0 commit comments

Comments
 (0)