boto/boto — pull request #1614 by danielgtaylor (2013-07-24 18:30:04+00:00)
Title: Prevent JSONDecodeError when handling CloudSearch responses, and instead throw SearchServiceExceptions

This PR applies #1555 from @adrian-sgn and adds tests to ensure its behavior.

Before the patch is applied:

```
======================================================================
ERROR: test_response (tests.unit.cloudsearch.test_search.CloudSearchErrorTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/taylordt/Projects/Amazon/boto/tests/unit/cloudsearch/test_search.py", line 379, in test_response
search.search(q='Test')
File "/Users/taylordt/Projects/Amazon/boto/boto/cloudsearch/search.py", line 277, in search
return self(query)
File "/Users/taylordt/Projects/Amazon/boto/boto/cloudsearch/search.py", line 292, in __call__
data = json.loads(r.content)
File "/Users/taylordt/Projects/Amazon/boto/venv/lib/python2.7/site-packages/simplejson/__init__.py", line 451, in loads
return _default_decoder.decode(s)
File "/Users/taylordt/Projects/Amazon/boto/venv/lib/python2.7/site-packages/simplejson/decoder.py", line 402, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/Users/taylordt/Projects/Amazon/boto/venv/lib/python2.7/site-packages/simplejson/decoder.py", line 420, in raw_decode
raise JSONDecodeError("No JSON object could be decoded", s, idx)
JSONDecodeError: No JSON object could be decoded: line 1 column 0 (char 0)
-------------------- >> begin captured logging << --------------------
requests.packages.urllib3.connectionpool: INFO: Starting new HTTP connection (1): search-demo-userdomain.us-east-1.cloudsearch.amazonaws.com
requests.packages.urllib3.connectionpool: DEBUG: "GET /2011-02-01/search?q=Test&start=0&size=10 HTTP/1.1" 500 60
--------------------- >> end captured logging << ---------------------

======================================================================
ERROR: test_response (tests.unit.cloudsearch.test_search.CloudSearchUnauthorizedTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/taylordt/Projects/Amazon/boto/tests/unit/cloudsearch/test_search.py", line 391, in test_response
search.search(q='Test')
File "/Users/taylordt/Projects/Amazon/boto/boto/cloudsearch/search.py", line 277, in search
return self(query)
File "/Users/taylordt/Projects/Amazon/boto/boto/cloudsearch/search.py", line 292, in __call__
data = json.loads(r.content)
File "/Users/taylordt/Projects/Amazon/boto/venv/lib/python2.7/site-packages/simplejson/__init__.py", line 451, in loads
return _default_decoder.decode(s)
File "/Users/taylordt/Projects/Amazon/boto/venv/lib/python2.7/site-packages/simplejson/decoder.py", line 402, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/Users/taylordt/Projects/Amazon/boto/venv/lib/python2.7/site-packages/simplejson/decoder.py", line 420, in raw_decode
raise JSONDecodeError("No JSON object could be decoded", s, idx)
JSONDecodeError: No JSON object could be decoded: line 1 column 0 (char 0)
-------------------- >> begin captured logging << --------------------
requests.packages.urllib3.connectionpool: INFO: Starting new HTTP connection (1): search-demo-userdomain.us-east-1.cloudsearch.amazonaws.com
requests.packages.urllib3.connectionpool: DEBUG: "GET /2011-02-01/search?q=Test&start=0&size=10 HTTP/1.1" 200 59
--------------------- >> end captured logging << ---------------------

----------------------------------------------------------------------
Ran 51 tests in 0.156s

FAILED (errors=2)
```

After the patch is applied:

```
...
test_response (tests.unit.cloudsearch.test_search.CloudSearchNonJsonTest) ... ok
test_response (tests.unit.cloudsearch.test_search.CloudSearchUnauthorizedTest) ... ok

----------------------------------------------------------------------
Ran 51 tests in 0.141s

OK
```