Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(29)

Unified Diff: third_party/boto/tests/unit/cloudsearch2/test_exceptions.py

Issue 698893003: Update checked in version of gsutil to version 4.6 (Closed) Base URL: http://dart.googlecode.com/svn/third_party/gsutil/
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/boto/tests/unit/cloudsearch2/test_exceptions.py
===================================================================
--- third_party/boto/tests/unit/cloudsearch2/test_exceptions.py (revision 0)
+++ third_party/boto/tests/unit/cloudsearch2/test_exceptions.py (revision 0)
@@ -0,0 +1,37 @@
+import mock
+from boto.compat import json
+from tests.unit import unittest
+
+from .test_search import HOSTNAME, CloudSearchSearchBaseTest
+from boto.cloudsearch2.search import SearchConnection, SearchServiceException
+
+
+def fake_loads_value_error(content, *args, **kwargs):
+ """Callable to generate a fake ValueError"""
+ raise ValueError("HAHAHA! Totally not simplejson & you gave me bad JSON.")
+
+
+def fake_loads_json_error(content, *args, **kwargs):
+ """Callable to generate a fake JSONDecodeError"""
+ raise json.JSONDecodeError('Using simplejson & you gave me bad JSON.',
+ '', 0)
+
+
+class CloudSearchJSONExceptionTest(CloudSearchSearchBaseTest):
+ response = '{}'
+
+ def test_no_simplejson_value_error(self):
+ with mock.patch.object(json, 'loads', fake_loads_value_error):
+ search = SearchConnection(endpoint=HOSTNAME)
+
+ with self.assertRaisesRegexp(SearchServiceException, 'non-json'):
+ search.search(q='test')
+
+ @unittest.skipUnless(hasattr(json, 'JSONDecodeError'),
+ 'requires simplejson')
+ def test_simplejson_jsondecodeerror(self):
+ with mock.patch.object(json, 'loads', fake_loads_json_error):
+ search = SearchConnection(endpoint=HOSTNAME)
+
+ with self.assertRaisesRegexp(SearchServiceException, 'non-json'):
+ search.search(q='test')
Property changes on: third_party/boto/tests/unit/cloudsearch2/test_exceptions.py
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « third_party/boto/tests/unit/cloudsearch2/test_document.py ('k') | third_party/boto/tests/unit/cloudsearch2/test_search.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698