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

Side by Side Diff: tests/test_http.py

Issue 1539313002: Correct a typo (Closed) Base URL: https://github.com/rryk/google-api-python-client.git@master
Patch Set: Created 5 years 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright 2014 Google Inc. All Rights Reserved. 3 # Copyright 2014 Google Inc. All Rights Reserved.
4 # 4 #
5 # Licensed under the Apache License, Version 2.0 (the "License"); 5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License. 6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at 7 # You may obtain a copy of the License at
8 # 8 #
9 # http://www.apache.org/licenses/LICENSE-2.0 9 # http://www.apache.org/licenses/LICENSE-2.0
10 # 10 #
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 HttpMockWithSSLErrors(3, {'status': '200'}, '{"foo": "bar"}'), 628 HttpMockWithSSLErrors(3, {'status': '200'}, '{"foo": "bar"}'),
629 model.response, 629 model.response,
630 u'https://www.example.com/json_api_endpoint') 630 u'https://www.example.com/json_api_endpoint')
631 request._sleep = lambda _x: 0 # do nothing 631 request._sleep = lambda _x: 0 # do nothing
632 request._rand = lambda: 10 632 request._rand = lambda: 10
633 response = request.execute(num_retries=3) 633 response = request.execute(num_retries=3)
634 self.assertEqual({u'foo': u'bar'}, response) 634 self.assertEqual({u'foo': u'bar'}, response)
635 635
636 def test_retry_ssl_errors_resumable(self): 636 def test_retry_ssl_errors_resumable(self):
637 with open(datafile('small.png'), 'rb') as small_png_file: 637 with open(datafile('small.png'), 'rb') as small_png_file:
638 small_png_file_descriptor = BytesIO(small_png_file.read()) 638 small_png_fd = BytesIO(small_png_file.read())
639 upload = MediaIoBaseUpload(fd=small_png_file, mimetype='image/png', 639 upload = MediaIoBaseUpload(fd=small_png_fd, mimetype='image/png',
640 chunksize=500, resumable=True) 640 chunksize=500, resumable=True)
641 model = JsonModel() 641 model = JsonModel()
642 642
643 request = HttpRequest( 643 request = HttpRequest(
644 HttpMockWithSSLErrors( 644 HttpMockWithSSLErrors(
645 3, {'status': '200', 'location': 'location'}, '{"foo": "bar"}'), 645 3, {'status': '200', 'location': 'location'}, '{"foo": "bar"}'),
646 model.response, 646 model.response,
647 u'https://www.example.com/file_upload', 647 u'https://www.example.com/file_upload',
648 method='POST', 648 method='POST',
649 resumable=upload) 649 resumable=upload)
650 request._sleep = lambda _x: 0 # do nothing 650 request._sleep = lambda _x: 0 # do nothing
651 request._rand = lambda: 10 651 request._rand = lambda: 10
652 response = request.execute(num_retries=3) 652 response = request.execute(num_retries=3)
653 self.assertEqual({u'foo': u'bar'}, response) 653 self.assertEqual({u'foo': u'bar'}, response)
654 654
655 def test_retry(self): 655 def test_retry(self):
656 num_retries = 5 656 num_retries = 5
657 resp_seq = [({'status': '500'}, '')] * num_retries 657 resp_seq = [({'status': '500'}, '')] * num_retries
658 resp_seq.append(({'status': '200'}, '{}')) 658 resp_seq.append(({'status': '200'}, '{}'))
659 659
660 http = HttpMockSequence(resp_seq) 660 http = HttpMockSequence(resp_seq)
661 model = JsonModel() 661 model = JsonModel()
662 uri = u'https://www.googleapis.com/someapi/v1/collection/?foo=bar' 662 uri = u'https://www.googleapis.com/someapi/v1/collection/?foo=bar'
663 method = u'POST' 663 method = u'POST'
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
1084 model.response, 1084 model.response,
1085 'https://www.googleapis.com/someapi/v1/collection/?foo=bar', 1085 'https://www.googleapis.com/someapi/v1/collection/?foo=bar',
1086 method='GET', 1086 method='GET',
1087 headers={}) 1087 headers={})
1088 self.assertRaises(HttpError, request.execute) 1088 self.assertRaises(HttpError, request.execute)
1089 1089
1090 1090
1091 if __name__ == '__main__': 1091 if __name__ == '__main__':
1092 logging.getLogger().setLevel(logging.ERROR) 1092 logging.getLogger().setLevel(logging.ERROR)
1093 unittest.main() 1093 unittest.main()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698