Merge lp:~elachuni/piston-mini-client/fix-tests into lp:piston-mini-client

Proposed by Anthony Lenton
Status: Merged
Approved by: Anthony Lenton
Approved revision: 66
Merged at revision: 61
Proposed branch: lp:~elachuni/piston-mini-client/fix-tests
Merge into: lp:piston-mini-client
Diff against target: 672 lines (+123/-102)
13 files modified
piston_mini_client/__init__.py (+25/-24)
piston_mini_client/auth.py (+3/-2)
piston_mini_client/failhandlers.py (+2/-2)
piston_mini_client/tests/test_auth.py (+5/-0)
piston_mini_client/tests/test_disable_ssl_check.py (+3/-3)
piston_mini_client/tests/test_failhandlers.py (+4/-4)
piston_mini_client/tests/test_log_to_file.py (+3/-3)
piston_mini_client/tests/test_pep8.py (+21/-28)
piston_mini_client/tests/test_resource.py (+39/-26)
piston_mini_client/tests/test_serializers.py (+1/-1)
piston_mini_client/tests/test_timeout.py (+4/-4)
piston_mini_client/tests/test_validators.py (+8/-2)
piston_mini_client/validators.py (+5/-3)
To merge this branch: bzr merge lp:~elachuni/piston-mini-client/fix-tests
Reviewer Review Type Date Requested Status
Jonathan Lange (community) Approve
software-store-developers Pending
Review via email: mp+117306@code.launchpad.net

Commit message

Made tests pass with the latest pep8 release.

Description of the change

This branch fixes the tests that were failing in trunk:
 - The latest pep8 release changes the internal layout of the module, so the test that uses it needed to apply matching changes.
 - oauth is still broken on Python 3 (it attempts to import urlparse, for starters), so the OAuth test is skipped on Python 3.

To post a comment you must log in.
Revision history for this message
Jonathan Lange (jml) wrote :

Looks good to me. Thanks.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'piston_mini_client/__init__.py'
2--- piston_mini_client/__init__.py 2012-07-30 15:59:14 +0000
3+++ piston_mini_client/__init__.py 2012-07-30 17:16:48 +0000
4@@ -212,8 +212,8 @@
5 data = {}
6 for att in self._atts:
7 if not hasattr(self, att):
8- raise ValueError("Attempted to serialize attribute '%s'"
9- % att)
10+ raise ValueError(
11+ "Attempted to serialize attribute '%s'" % att)
12 data[att] = getattr(self, att)
13 return data
14
15@@ -333,8 +333,8 @@
16 def _get_http_obj_for_scheme(self, scheme):
17 proxy_info = self._get_proxy_info(scheme)
18 http = None
19- if (self._disable_ssl_validation or
20- os.environ.get(DISABLE_SSL_VALIDATION_ENVVAR)):
21+ check_disabled_in_env = os.environ.get(DISABLE_SSL_VALIDATION_ENVVAR)
22+ if self._disable_ssl_validation or check_disabled_in_env:
23 try:
24 http = httplib2.Http(
25 cache=self._httplib2_cache,
26@@ -346,7 +346,7 @@
27 pass
28 if http is None:
29 http = httplib2.Http(cache=self._httplib2_cache,
30- timeout=self._timeout, proxy_info=proxy_info)
31+ timeout=self._timeout, proxy_info=proxy_info)
32 return http
33
34 def _get_proxy_info(self, scheme):
35@@ -396,10 +396,10 @@
36 path += urlencode(args)
37 headers = self._prepare_headers(extra_headers=extra_headers)
38 return self._request(path, method='GET', scheme=scheme,
39- headers=headers)
40+ headers=headers)
41
42 def _post(self, path, data=None, content_type=None, scheme=None,
43- extra_headers=None):
44+ extra_headers=None):
45 """Perform an HTTP POST request.
46
47 The provided ``path`` is appended to this api's ``_service_root``
48@@ -424,12 +424,12 @@
49 will be added to the http request.
50 """
51 body, headers = self._prepare_request(data, content_type,
52- extra_headers=extra_headers)
53+ extra_headers=extra_headers)
54 return self._request(path, method='POST', body=body,
55- headers=headers, scheme=scheme)
56+ headers=headers, scheme=scheme)
57
58 def _put(self, path, data=None, content_type=None, scheme=None,
59- extra_headers=None):
60+ extra_headers=None):
61 """Perform an HTTP PUT request.
62
63 The provided ``path`` is appended to this api's ``_service_root``
64@@ -454,9 +454,9 @@
65 will be added to the http request.
66 """
67 body, headers = self._prepare_request(data, content_type,
68- extra_headers=extra_headers)
69+ extra_headers=extra_headers)
70 return self._request(path, method='PUT', body=body,
71- headers=headers, scheme=scheme)
72+ headers=headers, scheme=scheme)
73
74 def _delete(self, path, scheme=None, extra_headers=None):
75 """Perform an HTTP DELETE request.
76@@ -473,10 +473,10 @@
77 """
78 headers = self._prepare_headers(extra_headers=extra_headers)
79 return self._request(path, method='DELETE', scheme=scheme,
80- headers=headers)
81+ headers=headers)
82
83 def _prepare_request(self, data=None, content_type=None,
84- extra_headers=None):
85+ extra_headers=None):
86 """Put together a set of headers and a body for a request.
87
88 If ``content_type`` is not provided, ``self.default_content_type``
89@@ -550,8 +550,8 @@
90 if self.log_filename:
91 self._dump_request(url, method, body, headers)
92 try:
93- response, response_body = self._http[scheme].request(url,
94- method=method, body=body, headers=headers)
95+ response, response_body = self._http[scheme].request(
96+ url, method=method, body=body, headers=headers)
97 except AttributeError as e:
98 # Special case out httplib2's way of telling us unable to connect
99 if e.args[0] == "'NoneType' object has no attribute 'makefile'":
100@@ -560,10 +560,10 @@
101 raise
102 except socket.timeout as e:
103 raise TimeoutError('Timed out attempting to connect to %s' %
104- self._service_root)
105+ self._service_root)
106 except (socket.gaierror, socket.error) as e:
107- raise SocketError('connecting to %s: %s' % (self._service_root,
108- e.message))
109+ msg = 'connecting to %s: %s' % (self._service_root, e.message)
110+ raise SocketError(msg)
111 if self.log_filename:
112 self._dump_response(response, response_body)
113 handler = self.fail_handler(url, method, body, headers)
114@@ -573,16 +573,16 @@
115 def _dump_request(self, url, method, body, headers):
116 try:
117 with open(self.log_filename, 'a') as f:
118- f.write("{0}: {1}".format(datetime.now(),
119- format_request(url, method, body, headers)))
120+ formatted = format_request(url, method, body, headers)
121+ f.write("{0}: {1}".format(datetime.now(), formatted))
122 except IOError:
123 pass
124
125 def _dump_response(self, response, body):
126 try:
127 with open(self.log_filename, 'a') as f:
128- f.write("{0}: {1}".format(datetime.now(),
129- format_response(response, body)))
130+ formatted = format_response(response, body)
131+ f.write("{0}: {1}".format(datetime.now(), formatted))
132 except IOError:
133 pass
134
135@@ -595,7 +595,8 @@
136 cached_value = self._http[scheme].cache.get(
137 httplib2.urlnorm(url)[-1])
138 if cached_value:
139- info, content = cached_value.decode("utf-8").split('\r\n\r\n', 1)
140+ info, content = cached_value.decode("utf-8").split(
141+ '\r\n\r\n', 1)
142 return content
143
144 def _path2url(self, path, scheme=None):
145
146=== modified file 'piston_mini_client/auth.py'
147--- piston_mini_client/auth.py 2012-06-14 08:19:19 +0000
148+++ piston_mini_client/auth.py 2012-07-30 17:16:48 +0000
149@@ -12,6 +12,7 @@
150
151 import base64
152
153+
154 class OAuthAuthorizer(object):
155 """Authenticate to OAuth protected APIs."""
156 def __init__(self, token_key, token_secret, consumer_key, consumer_secret,
157@@ -33,13 +34,13 @@
158 # Import oauth here so that you don't need it if you're not going
159 # to use it. Plan B: move this out into a separate oauth module.
160 from oauth.oauth import (OAuthRequest, OAuthConsumer, OAuthToken,
161- OAuthSignatureMethod_PLAINTEXT)
162+ OAuthSignatureMethod_PLAINTEXT)
163 consumer = OAuthConsumer(self.consumer_key, self.consumer_secret)
164 token = OAuthToken(self.token_key, self.token_secret)
165 oauth_request = OAuthRequest.from_consumer_and_token(
166 consumer, token, http_url=url)
167 oauth_request.sign_request(OAuthSignatureMethod_PLAINTEXT(),
168- consumer, token)
169+ consumer, token)
170 headers.update(oauth_request.to_header(self.oauth_realm))
171
172
173
174=== modified file 'piston_mini_client/failhandlers.py'
175--- piston_mini_client/failhandlers.py 2012-07-19 15:38:19 +0000
176+++ piston_mini_client/failhandlers.py 2012-07-30 17:16:48 +0000
177@@ -113,7 +113,7 @@
178 raise APIError('No status code in response')
179 if self.was_error(response):
180 raise APIError('%s: %s' % (response['status'], response), body,
181- data=self.data)
182+ data=self.data)
183 return body
184
185
186@@ -197,5 +197,5 @@
187 status = response.get('status')
188 exception_class = self.exceptions.get(status, APIError)
189 raise exception_class('%s: %s' % (status, response), body,
190- data=self.data)
191+ data=self.data)
192 return body
193
194=== modified file 'piston_mini_client/tests/test_auth.py'
195--- piston_mini_client/tests/test_auth.py 2012-06-14 08:19:19 +0000
196+++ piston_mini_client/tests/test_auth.py 2012-07-30 17:16:48 +0000
197@@ -2,6 +2,7 @@
198 # Copyright 2010-2012 Canonical Ltd. This software is licensed under the
199 # GNU Lesser General Public License version 3 (see the file LICENSE).
200
201+import sys
202 from piston_mini_client.auth import OAuthAuthorizer, BasicAuthorizer
203 from unittest import TestCase
204
205@@ -19,6 +20,10 @@
206
207 class OAuthAuthorizerTestCase(TestCase):
208 def test_sign_request(self):
209+ if sys.version_info[0] == 3:
210+ # Skip on Python 3 as oauth is still broken there.
211+ # don't use skipIf as it's missing on python2.6
212+ return
213 auth = OAuthAuthorizer('tkey', 'tsecret', 'ckey', 'csecret')
214 url = 'http://example.com/api'
215 headers = {}
216
217=== modified file 'piston_mini_client/tests/test_disable_ssl_check.py'
218--- piston_mini_client/tests/test_disable_ssl_check.py 2012-03-30 17:17:49 +0000
219+++ piston_mini_client/tests/test_disable_ssl_check.py 2012-07-30 17:16:48 +0000
220@@ -35,14 +35,14 @@
221 api = DentistAPI()
222
223 self.assertTrue('disable_ssl_certificate_validation' not in
224- mock_http.call_args[1])
225+ mock_http.call_args[1])
226
227 @patch('httplib2.Http')
228 def test_disable_via_constructor(self, mock_http):
229 api = DentistAPI(disable_ssl_validation=True)
230
231 self.assertTrue('disable_ssl_certificate_validation' in
232- mock_http.call_args[1])
233+ mock_http.call_args[1])
234
235 @patch('httplib2.Http')
236 def test_disable_via_envvar(self, mock_http):
237@@ -50,4 +50,4 @@
238 api = DentistAPI()
239
240 self.assertTrue('disable_ssl_certificate_validation' in
241- mock_http.call_args[1])
242+ mock_http.call_args[1])
243
244=== modified file 'piston_mini_client/tests/test_failhandlers.py'
245--- piston_mini_client/tests/test_failhandlers.py 2012-07-19 15:56:33 +0000
246+++ piston_mini_client/tests/test_failhandlers.py 2012-07-30 17:16:48 +0000
247@@ -120,7 +120,7 @@
248 handler = ExceptionFailHandler('/foo', 'GET', '', {})
249 for status in bad_status:
250 self.assertRaises(APIError, handler.handle,
251- {'status': status}, '')
252+ {'status': status}, '')
253
254
255 class NoneFailHandlerTestCase(TestCase):
256@@ -253,7 +253,7 @@
257 mock_request.return_value = {'status': '200'}, '{"foo": "bar"}'
258
259 self.assertTrue(isinstance(self.api.get_plant(),
260- PistonResponseObject))
261+ PistonResponseObject))
262
263 @patch('httplib2.Http.request')
264 def test_interacts_well_with_returns_list_of(self, mock_request):
265@@ -285,7 +285,7 @@
266 handler = MultiExceptionFailHandler('/foo', 'GET', '', {})
267 for status, exception in bad_status.items():
268 self.assertRaises(exception, handler.handle, {'status': status},
269- '')
270+ '')
271
272 @patch('httplib2.Http.request')
273 def test_interacts_well_with_returns_json_on_fail(self, mock_request):
274@@ -324,7 +324,7 @@
275 mock_request.return_value = {'status': '200'}, '{"foo": "bar"}'
276
277 self.assertTrue(isinstance(self.api.get_plant(),
278- PistonResponseObject))
279+ PistonResponseObject))
280
281 @patch('httplib2.Http.request')
282 def test_interacts_well_with_returns_list_of(self, mock_request):
283
284=== modified file 'piston_mini_client/tests/test_log_to_file.py'
285--- piston_mini_client/tests/test_log_to_file.py 2012-06-14 08:10:28 +0000
286+++ piston_mini_client/tests/test_log_to_file.py 2012-07-30 17:16:48 +0000
287@@ -19,14 +19,14 @@
288 @returns_json
289 def poke(self, data=None):
290 return self._post('/poke/', data=data,
291- extra_headers={'location': 'ribs'})
292+ extra_headers={'location': 'ribs'})
293
294
295 class LogToFileTestCase(TestCase):
296 @patch('httplib2.Http.request')
297 def test_requests_are_dumped_to_file(self, mock_request):
298 mock_request.return_value = ({'status': '201', 'x-foo': 'bar'},
299- '"Go away!"')
300+ '"Go away!"')
301
302 with NamedTemporaryFile() as fp:
303 api = AnnoyAPI(log_filename=fp.name)
304@@ -41,7 +41,7 @@
305 self.assertTrue(lines[0].endswith(
306 'Request: POST http://test.info/api/1.0/poke/'))
307 self.assertEqual(['Content-type: application/json',
308- 'location: ribs', '', '[1, 2, 3]'], lines[1:5])
309+ 'location: ribs', '', '[1, 2, 3]'], lines[1:5])
310 self.assertTrue(lines[5].endswith('Response: 201'))
311 self.assertEqual(['x-foo: bar', '', '"Go away!"', ''], lines[6:])
312
313
314=== modified file 'piston_mini_client/tests/test_pep8.py'
315--- piston_mini_client/tests/test_pep8.py 2012-03-30 17:17:49 +0000
316+++ piston_mini_client/tests/test_pep8.py 2012-07-30 17:16:48 +0000
317@@ -15,36 +15,29 @@
318 packages = [piston_mini_client]
319 exclude = ['socks.py'] # Leave 3rd party dep. alone.
320
321- def message(self, text):
322- self.errors.append(text)
323-
324- def setUp(self):
325- self.errors = []
326-
327- class Options(object):
328- exclude = self.exclude
329- filename = ['*.py']
330- testsuite = ''
331- doctest = ''
332- counters = defaultdict(int)
333- messages = {}
334- verbose = 0
335- quiet = 0
336- repeat = True
337- show_source = False
338- show_pep8 = False
339- select = []
340- ignore = []
341- max_line_length = 79
342- pep8.options = Options()
343- pep8.message = self.message
344- Options.physical_checks = pep8.find_checks('physical_line')
345- Options.logical_checks = pep8.find_checks('logical_line')
346-
347 def test_all_code(self):
348+ pep8style = pep8.StyleGuide(
349+ counters=defaultdict(int),
350+ doctest='',
351+ exclude=self.exclude,
352+ filename=['*.py'],
353+ ignore=[],
354+ messages={},
355+ repeat=True,
356+ select=[],
357+ show_pep8=False,
358+ show_source=False,
359+ max_line_length=79,
360+ quiet=0,
361+ statistics=False,
362+ testsuite='',
363+ verbose=0,
364+ )
365+
366 for package in self.packages:
367- pep8.input_dir(os.path.dirname(package.__file__))
368- self.assertEqual([], self.errors)
369+ pep8style.input_dir(os.path.dirname(package.__file__))
370+ self.assertEqual(pep8style.options.report.total_errors, 0)
371+
372
373 if __name__ == "__main__":
374 unittest.main()
375
376=== modified file 'piston_mini_client/tests/test_resource.py'
377--- piston_mini_client/tests/test_resource.py 2012-07-30 15:59:14 +0000
378+++ piston_mini_client/tests/test_resource.py 2012-07-30 17:16:48 +0000
379@@ -27,11 +27,11 @@
380
381 @patch('httplib2.Http.request')
382 def test_request(self, mock_request):
383- mock_request.return_value = ({'status': '200'
384- }, 'hello world!')
385+ mock_request.return_value = ({'status': '200'}, 'hello world!')
386 api = self.CoffeeAPI()
387 api._request('/foo', 'POST', body='foo=bar')
388- mock_request.assert_called_with('http://localhost:12345/foo',
389+ mock_request.assert_called_with(
390+ 'http://localhost:12345/foo',
391 body='foo=bar', headers={}, method='POST')
392
393 @patch('httplib2.Http.request')
394@@ -68,7 +68,8 @@
395 cache = httplib2.FileCache(tmpdir, safe=safename)
396 http = httplib2.Http(cache=cache)
397 cachekey = self.CoffeeAPI.default_service_root + path
398- http.cache.set(cachekey.encode('utf-8'),
399+ http.cache.set(
400+ cachekey.encode('utf-8'),
401 "header\r\n\r\nmy_cached_body_from_long_path\n".encode('utf-8'))
402 # ensure that we trigger a error like when offline (no dns)
403 mock_request.side_effect = httplib2.ServerNotFoundError("")
404@@ -83,11 +84,11 @@
405 def test_auth_request(self, mock_request):
406 mock_request.return_value = ({'status': '200'}, '""')
407 api = self.CoffeeAPI(auth=BasicAuthorizer(username='foo',
408- password='bar'))
409+ password='bar'))
410 api._request('/fee', 'GET')
411 kwargs = mock_request.call_args[1]
412 self.assertEqual(kwargs['headers']['Authorization'],
413- 'Basic Zm9vOmJhcg==')
414+ 'Basic Zm9vOmJhcg==')
415 self.assertEqual(kwargs['method'], 'GET')
416
417 @patch('httplib2.Http.request')
418@@ -116,10 +117,10 @@
419 mock_request.return_value = ({'status': '200'}, '""')
420 api = self.CoffeeAPI()
421 api._post('/serve', data={'foo': 'bar'},
422- content_type='application/x-www-form-urlencoded')
423+ content_type='application/x-www-form-urlencoded')
424 kwargs = mock_request.call_args[1]
425 self.assertEqual(kwargs['headers']['Content-type'],
426- 'application/x-www-form-urlencoded')
427+ 'application/x-www-form-urlencoded')
428 self.assertEqual(kwargs['method'], 'POST')
429
430 @patch('httplib2.Http.request')
431@@ -150,7 +151,7 @@
432 body = api._get('/simmer')
433 self.assertEqual(expected_body, body)
434 mock_request.assert_called_with('http://localhost:12345/simmer',
435- body='', headers={}, method='GET')
436+ body='', headers={}, method='GET')
437
438 @patch('httplib2.Http.request')
439 def test_get_with_extra_args(self, mock_request):
440@@ -187,7 +188,7 @@
441 api = self.CoffeeAPI()
442 api._request('/foo', 'GET', scheme='https')
443 mock_request.assert_called_with('https://localhost:12345/foo',
444- body='', headers={}, method='GET')
445+ body='', headers={}, method='GET')
446
447 @patch('httplib2.Http.request')
448 def test_get_scheme_switch_to_https(self, mock_request):
449@@ -195,14 +196,15 @@
450 api = self.CoffeeAPI()
451 api._get('/foo', scheme='https')
452 mock_request.assert_called_with('https://localhost:12345/foo',
453- body='', headers={}, method='GET')
454+ body='', headers={}, method='GET')
455
456 @patch('httplib2.Http.request')
457 def test_post_scheme_switch_to_https(self, mock_request):
458 mock_request.return_value = ({'status': '200'}, '""')
459 api = self.CoffeeAPI()
460 api._post('/foo', scheme='https')
461- mock_request.assert_called_with('https://localhost:12345/foo',
462+ mock_request.assert_called_with(
463+ 'https://localhost:12345/foo',
464 body='null', headers={'Content-type': 'application/json'},
465 method='POST')
466
467@@ -250,7 +252,8 @@
468 mock_request.return_value = ({'status': '200'}, '""')
469 api = self.CoffeeAPI()
470 api._put('/foo', scheme='https')
471- mock_request.assert_called_with('https://localhost:12345/foo',
472+ mock_request.assert_called_with(
473+ 'https://localhost:12345/foo',
474 body='null', headers={'Content-type': 'application/json'},
475 method='PUT')
476
477@@ -259,11 +262,11 @@
478 mock_request.return_value = ({'status': '200'}, '""')
479 api = self.CoffeeAPI()
480 api._put('/serve', data={'foo': 'bar'},
481- content_type='application/x-www-form-urlencoded')
482+ content_type='application/x-www-form-urlencoded')
483 kwargs = mock_request.call_args[1]
484 self.assertEqual(kwargs['body'], 'foo=bar')
485 self.assertEqual(kwargs['headers']['Content-type'],
486- 'application/x-www-form-urlencoded')
487+ 'application/x-www-form-urlencoded')
488 self.assertEqual(kwargs['method'], 'PUT')
489
490 @patch('httplib2.Http.request')
491@@ -273,17 +276,21 @@
492 api.extra_headers = {'X-Foo': 'bar'}
493 api._get('/foo')
494 expected_headers = {'X-Foo': 'bar'}
495- mock_request.assert_called_with('http://localhost:12345/foo',
496+ mock_request.assert_called_with(
497+ 'http://localhost:12345/foo',
498 body='', headers=expected_headers, method='GET')
499 api._delete('/foo')
500- mock_request.assert_called_with('http://localhost:12345/foo',
501+ mock_request.assert_called_with(
502+ 'http://localhost:12345/foo',
503 body='', headers=expected_headers, method='DELETE')
504 expected_headers['Content-type'] = 'application/json'
505 api._post('/foo')
506- mock_request.assert_called_with('http://localhost:12345/foo',
507+ mock_request.assert_called_with(
508+ 'http://localhost:12345/foo',
509 body='null', headers=expected_headers, method='POST')
510 api._put('/foo')
511- mock_request.assert_called_with('http://localhost:12345/foo',
512+ mock_request.assert_called_with(
513+ 'http://localhost:12345/foo',
514 body='null', headers=expected_headers, method='PUT')
515
516 @patch('httplib2.Http.request')
517@@ -292,17 +299,21 @@
518 api = self.CoffeeAPI()
519 api._get('/foo', extra_headers={'X-Foo': 'bar'})
520 expected_headers = {'X-Foo': 'bar'}
521- mock_request.assert_called_with('http://localhost:12345/foo',
522+ mock_request.assert_called_with(
523+ 'http://localhost:12345/foo',
524 body='', headers=expected_headers, method='GET')
525 api._delete('/foo', extra_headers={'X-Foo': 'bar'})
526- mock_request.assert_called_with('http://localhost:12345/foo',
527+ mock_request.assert_called_with(
528+ 'http://localhost:12345/foo',
529 body='', headers=expected_headers, method='DELETE')
530 expected_headers['Content-type'] = 'application/json'
531 api._post('/foo', extra_headers={'X-Foo': 'bar'})
532- mock_request.assert_called_with('http://localhost:12345/foo',
533+ mock_request.assert_called_with(
534+ 'http://localhost:12345/foo',
535 body='null', headers=expected_headers, method='POST')
536 api._put('/foo', extra_headers={'X-Foo': 'bar'})
537- mock_request.assert_called_with('http://localhost:12345/foo',
538+ mock_request.assert_called_with(
539+ 'http://localhost:12345/foo',
540 body='null', headers=expected_headers, method='PUT')
541
542 @patch('httplib2.Http.request')
543@@ -317,12 +328,14 @@
544 api = self.CoffeeAPI()
545 api.serializers = {'application/json': MySerializer()}
546 api._post('/foo', data=[])
547- mock_request.assert_called_with('http://localhost:12345/foo',
548+ mock_request.assert_called_with(
549+ 'http://localhost:12345/foo',
550 body=expected, headers={'Content-type': 'application/json'},
551 method='POST')
552
553 api._put('/foo', data=None)
554- mock_request.assert_called_with('http://localhost:12345/foo',
555+ mock_request.assert_called_with(
556+ 'http://localhost:12345/foo',
557 body=expected, headers={'Content-type': 'application/json'},
558 method='PUT')
559
560@@ -341,7 +354,7 @@
561 api = self.CoffeeAPI()
562 api._delete('/sugar/12', scheme='https')
563 mock_request.assert_called_with('https://localhost:12345/sugar/12',
564- body='', headers={}, method='DELETE')
565+ body='', headers={}, method='DELETE')
566
567 def test_cachedir_crash_race_lp803280(self):
568 def _simulate_race(path):
569
570=== modified file 'piston_mini_client/tests/test_serializers.py'
571--- piston_mini_client/tests/test_serializers.py 2012-03-30 17:17:49 +0000
572+++ piston_mini_client/tests/test_serializers.py 2012-07-30 17:16:48 +0000
573@@ -44,4 +44,4 @@
574 # Maybe we should flatly refuse to serialize nested structures?
575 serializer = FormSerializer()
576 self.assertEqual('foo=%7B%27a%27%3A+%27b%27%7D',
577- serializer.serialize({'foo': {'a': 'b'}}))
578+ serializer.serialize({'foo': {'a': 'b'}}))
579
580=== modified file 'piston_mini_client/tests/test_timeout.py'
581--- piston_mini_client/tests/test_timeout.py 2012-04-02 14:23:33 +0000
582+++ piston_mini_client/tests/test_timeout.py 2012-07-30 17:16:48 +0000
583@@ -25,7 +25,7 @@
584 api = LazyAPI(timeout=1)
585 self.assertEqual(1, api._timeout)
586 mock_http.assert_called_with(cache=None, proxy_info=None, timeout=1,
587- disable_ssl_certificate_validation=True)
588+ disable_ssl_certificate_validation=True)
589
590 @patch('os.environ.get')
591 @patch('httplib2.Http')
592@@ -34,7 +34,7 @@
593 api = LazyAPI()
594 self.assertEqual(3.14, api._timeout)
595 mock_http.assert_called_with(cache=None, proxy_info=None, timeout=3.14,
596- disable_ssl_certificate_validation=True)
597+ disable_ssl_certificate_validation=True)
598
599 @patch('os.environ.get')
600 @patch('httplib2.Http')
601@@ -47,7 +47,7 @@
602 @patch('os.environ.get')
603 @patch('httplib2.Http')
604 def test_no_nothing_falls_back_to_system_default(self, mock_http,
605- mock_get):
606+ mock_get):
607 class DefaultAPI(PistonAPI):
608 default_service_root = 'http://test.info/api/1.0/'
609
610@@ -63,7 +63,7 @@
611 api = LazyAPI()
612 self.assertEqual(42, api._timeout)
613 mock_http.assert_called_with(cache=None, proxy_info=None, timeout=42,
614- disable_ssl_certificate_validation=True)
615+ disable_ssl_certificate_validation=True)
616
617 @patch('httplib2.HTTPConnectionWithTimeout.connect')
618 def test_timeout_is_handled_by_failhandler(self, mock_connect):
619
620=== modified file 'piston_mini_client/tests/test_validators.py'
621--- piston_mini_client/tests/test_validators.py 2012-03-30 17:17:49 +0000
622+++ piston_mini_client/tests/test_validators.py 2012-07-30 17:16:48 +0000
623@@ -2,8 +2,14 @@
624 # Copyright 2010-2012 Canonical Ltd. This software is licensed under the
625 # GNU Lesser General Public License version 3 (see the file LICENSE).
626
627-from piston_mini_client.validators import (validate_pattern, validate,
628- validate_integer, oauth_protected, basic_protected, ValidationException)
629+from piston_mini_client.validators import (
630+ basic_protected,
631+ oauth_protected,
632+ validate,
633+ validate_integer,
634+ validate_pattern,
635+ ValidationException,
636+)
637 from piston_mini_client.auth import OAuthAuthorizer, BasicAuthorizer
638 from unittest import TestCase
639
640
641=== modified file 'piston_mini_client/validators.py'
642--- piston_mini_client/validators.py 2012-06-13 13:25:54 +0000
643+++ piston_mini_client/validators.py 2012-07-30 17:16:48 +0000
644@@ -42,7 +42,7 @@
645 if not re.match(pattern, kwargs[varname]):
646 raise ValidationException(
647 "Argument '%s' must match pattern '%s'" % (varname,
648- pattern))
649+ pattern))
650 elif required:
651 raise ValidationException(
652 "Required named argument '%s' missing" % varname)
653@@ -111,7 +111,8 @@
654 @wraps(func)
655 def wrapper(self, *args, **kwargs):
656 if not hasattr(self, '_auth') or self._auth is None:
657- raise ValidationException("This method is OAuth protected. "
658+ raise ValidationException(
659+ "This method is OAuth protected. "
660 "Pass in an 'auth' argument to the constructor.")
661 if not isinstance(self._auth, OAuthAuthorizer):
662 raise ValidationException("self.auth must be an OAuthAuthorizer.")
663@@ -128,7 +129,8 @@
664 @wraps(func)
665 def wrapper(self, *args, **kwargs):
666 if not hasattr(self, '_auth') or self._auth is None:
667- raise ValidationException("This method uses Basic auth. "
668+ raise ValidationException(
669+ "This method uses Basic auth. "
670 "Pass in an 'auth' argument to the constructor.")
671 if not isinstance(self._auth, BasicAuthorizer):
672 raise ValidationException("self.auth must be a BasicAuthorizer.")

Subscribers

People subscribed via source and target branches