Skip to content

Commit

Permalink
Merge pull request #296 from aio-libs/thehesiod/status_fix
Browse files Browse the repository at this point in the history
fix #190
  • Loading branch information
jettify committed Sep 8, 2017
2 parents 4ceef35 + 83ec16b commit 097e2a7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Changes
-------
0.4.6a0 (XXXX-XX-XX)
^^^^^^^^^^^^^^^^^^
*
* fix #190

0.4.5 (2017-09-05)
^^^^^^^^^^^^^^^^^^
Expand Down
7 changes: 7 additions & 0 deletions aiobotocore/endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,13 @@ def __init__(self, *args, **kwargs):
def status_code(self):
return self.status

@status_code.setter
def status_code(self, value):
# botocore tries to set this, see:
# https://github.com/aio-libs/aiobotocore/issues/190
# Luckily status is an attribute we can set
self.status = value

@property
def content(self):
# ClientResponse._content is set by the coroutine ClientResponse.read
Expand Down
11 changes: 11 additions & 0 deletions tests/test_patches.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import pytest
import hashlib
from dill.source import getsource
from yarl import URL

from aiobotocore.endpoint import ClientResponseProxy

from aiohttp.client_proto import ResponseHandler
from aiohttp import TCPConnector
Expand Down Expand Up @@ -67,3 +70,11 @@ def test_patches():
digest = hashlib.sha1(getsource(obj).encode('utf-8')).hexdigest()
assert digest in digests, \
"Digest of {} not found in: {}".format(obj.__name__, digests)


# NOTE: this doesn't require moto but needs to be marked to run with coverage
@pytest.mark.moto
def test_set_status_code():
resp = ClientResponseProxy('GET', URL('http://foo/bar'))
resp.status_code = 500
assert resp.status_code == 500

0 comments on commit 097e2a7

Please sign in to comment.