Permalink
Browse files

Fixes #17 Updated to use requests 1.x

Requests 1.x no longer has an error attribute in Response objects,
and Response objects now expect a `reason` attribute in the
raise_for_status() method when building the error message. This was
causing errors in tests as well as any requests.

requirements.txt now specifies requests >= 1.0.0

tests/utils has had MockResponses updated to reflect the API change,
as well test_properties_copied() in tests/test_resource.

Tests have been run in requests 1.0.0 and 1.1.0
  • Loading branch information...
1 parent cf96ad2 commit 0639cc887e834e47e252eaed5b5cf0931d305498 @Zintinio Zintinio committed Feb 3, 2013
Showing with 8 additions and 6 deletions.
  1. +1 −1 requirements.txt
  2. +3 −1 soundcloud/resource.py
  3. +2 −2 soundcloud/tests/test_resource.py
  4. +2 −2 soundcloud/tests/utils.py
View
2 requirements.txt
@@ -1,4 +1,4 @@
nose==1.1.2
fudge==1.0.3
-requests>=0.14.0
+requests>=1.0.0
simplejson>=2.0
View
4 soundcloud/resource.py
@@ -58,6 +58,8 @@ def wrapped_resource(response):
else:
result = Resource(content)
result.raw_data = response.content
- for attr in ['url', 'status_code', 'error']:
+
+ for attr in ('url', 'status_code', 'reason'):
setattr(result, attr, getattr(response, attr))
+
return result
View
4 soundcloud/tests/test_resource.py
@@ -28,9 +28,9 @@ def test_properties_copied():
"""Certain properties should be copied to the wrapped resource."""
response = MockResponse(json.dumps({'foo': 'bar'}),
status_code=200,
- error='This is an error',
+ reason='OK',
url='http://example.com')
resource = wrapped_resource(response)
eq_(200, resource.status_code)
- eq_('This is an error', resource.error)
+ eq_('OK', resource.reason)
eq_('http://example.com', resource.url)
View
4 soundcloud/tests/utils.py
@@ -2,8 +2,8 @@
class MockResponse(Response):
- def __init__(self, content, status_code=200, url=None, error=None):
+ def __init__(self, content, status_code=200, url=None, reason=None):
self._content = content
self.status_code = status_code
self.url = url
- self.error = error
+ self.reason = reason

0 comments on commit 0639cc8

Please sign in to comment.