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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 import mock
2 from boto.compat import json
3 from tests.unit import unittest
4
5 from .test_search import HOSTNAME, CloudSearchSearchBaseTest
6 from boto.cloudsearch2.search import SearchConnection, SearchServiceException
7
8
9 def fake_loads_value_error(content, *args, **kwargs):
10 """Callable to generate a fake ValueError"""
11 raise ValueError("HAHAHA! Totally not simplejson & you gave me bad JSON.")
12
13
14 def fake_loads_json_error(content, *args, **kwargs):
15 """Callable to generate a fake JSONDecodeError"""
16 raise json.JSONDecodeError('Using simplejson & you gave me bad JSON.',
17 '', 0)
18
19
20 class CloudSearchJSONExceptionTest(CloudSearchSearchBaseTest):
21 response = '{}'
22
23 def test_no_simplejson_value_error(self):
24 with mock.patch.object(json, 'loads', fake_loads_value_error):
25 search = SearchConnection(endpoint=HOSTNAME)
26
27 with self.assertRaisesRegexp(SearchServiceException, 'non-json'):
28 search.search(q='test')
29
30 @unittest.skipUnless(hasattr(json, 'JSONDecodeError'),
31 'requires simplejson')
32 def test_simplejson_jsondecodeerror(self):
33 with mock.patch.object(json, 'loads', fake_loads_json_error):
34 search = SearchConnection(endpoint=HOSTNAME)
35
36 with self.assertRaisesRegexp(SearchServiceException, 'non-json'):
37 search.search(q='test')
OLDNEW
« 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