Skip to content

Commit

Permalink
Merge pull request #71 from uploadcare/v.1.2.10
Browse files Browse the repository at this point in the history
handle head and option responses, update widget
  • Loading branch information
dmitry-mukhin committed Dec 4, 2014
2 parents 3e24eb8 + a2beabf commit 39ab2eb
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ script: nosetests tests
notifications:
email:
recipients:
- ak@whitescape.com
- ak@uploadcare.com
- [email protected]
on_success: change
on_failure: change
7 changes: 7 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ History
-------


1.2.10
~~~~~

- handle responses for HEAD and OPTION requests
- update widget to 1.4.6


1.2.9
~~~~~

Expand Down
2 changes: 1 addition & 1 deletion pyuploadcare/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from __future__ import unicode_literals

__version__ = '1.2.9'
__version__ = '1.2.10'

from .api_resources import File, FileList, FileGroup
from .exceptions import (
Expand Down
4 changes: 4 additions & 0 deletions pyuploadcare/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,13 @@ def _request():
# No content.
if response.status_code == 204:
return {}
if verb.lower() == 'options':
return ''

if 200 <= response.status_code < 300:
if _content_type_from_response(response).endswith(('/json', '+json')):
if verb.lower() == 'head':
return ''
try:
return response.json()
except ValueError as exc:
Expand Down
2 changes: 1 addition & 1 deletion pyuploadcare/dj/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
conf.secret = settings.UPLOADCARE['secret']


widget_version = settings.UPLOADCARE.get('widget_version', '1.4.0')
widget_version = settings.UPLOADCARE.get('widget_version', '1.4.6')

hosted_url = 'https://ucarecdn.com/widget/{version}/uploadcare/uploadcare-{version}.min.js'.format(
version=widget_version)
Expand Down
17 changes: 0 additions & 17 deletions pyuploadcare/dj/static/uploadcare/uploadcare-1.4.0.min.js

This file was deleted.

17 changes: 17 additions & 0 deletions pyuploadcare/dj/static/uploadcare/uploadcare-1.4.6.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

setup(
name='pyuploadcare',
version='1.2.9',
version='1.2.10',
description='Python library for Uploadcare.com',
long_description=(
open('README.rst').read() + '\n\n' + open('HISTORY.rst').read()
Expand Down
12 changes: 12 additions & 0 deletions tests/functional/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,15 @@ def test_request_headers(self, request):
self.assertIn('User-Agent', headers)
self.assertEqual(headers['Accept'], 'application/vnd.uploadcare-v0.1+json')
self.assertEqual(headers['User-Agent'], self.user_agent)

@patch('requests.sessions.Session.request', autospec=True)
def test_head(self, request):
request.return_value = MockResponse(200, b'')

rest_request('HEAD', 'files/')

@patch('requests.sessions.Session.request', autospec=True)
def test_options(self, request):
request.return_value = MockResponse(200, b'')

rest_request('OPTIONS', 'files/')

0 comments on commit 39ab2eb

Please sign in to comment.