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

Side by Side Diff: infra_libs/test/httplib2_utils_test.py

Issue 2127373005: Fix RetriableHttp (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Fix RetriableHttp Created 4 years, 5 months 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 | « infra_libs/httplib2_utils.py ('k') | infra_libs/ts_mon/common/monitors.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import os 5 import os
6 import socket 6 import socket
7 import time 7 import time
8 import unittest 8 import unittest
9 9
10 import infra_libs 10 import infra_libs
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 131
132 class RetriableHttplib2Test(unittest.TestCase): 132 class RetriableHttplib2Test(unittest.TestCase):
133 def setUp(self): 133 def setUp(self):
134 super(RetriableHttplib2Test, self).setUp() 134 super(RetriableHttplib2Test, self).setUp()
135 self.http = infra_libs.RetriableHttp(httplib2.Http()) 135 self.http = infra_libs.RetriableHttp(httplib2.Http())
136 self.http._http.request = mock.create_autospec(self.http._http.request, 136 self.http._http.request = mock.create_autospec(self.http._http.request,
137 spec_set=True) 137 spec_set=True)
138 138
139 _MOCK_REQUEST = mock.call('http://foo/', 'GET', None) 139 _MOCK_REQUEST = mock.call('http://foo/', 'GET', None)
140 140
141 def test_authorize(self):
142 http = infra_libs.RetriableHttp(httplib2.Http())
143 creds = infra_libs.get_signed_jwt_assertion_credentials(
144 'valid_creds.json',
145 service_accounts_creds_root=DATA_DIR)
146 creds.authorize(http)
147
141 def test_delegate_get_attr(self): 148 def test_delegate_get_attr(self):
142 """RetriableHttp should delegate getting attribute except request() to 149 """RetriableHttp should delegate getting attribute except request() to
143 Http""" 150 Http"""
144 self.http._http.clear_credentials = mock.create_autospec( 151 self.http._http.clear_credentials = mock.create_autospec(
145 self.http._http.clear_credentials, spec_set=True) 152 self.http._http.clear_credentials, spec_set=True)
146 self.http.clear_credentials() 153 self.http.clear_credentials()
147 self.http._http.clear_credentials.assert_called_once_with() 154 self.http._http.clear_credentials.assert_called_once_with()
148 155
149 def test_delegate_set_attr(self): 156 def test_delegate_set_attr(self):
150 """RetriableHttp should delegate setting attributes to Http""" 157 """RetriableHttp should delegate setting attributes to Http"""
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 ('.*', {'status': 404}, '')]) 351 ('.*', {'status': 404}, '')])
345 response, body = http.request('https://mywebserver.woo.hoo', 'GET') 352 response, body = http.request('https://mywebserver.woo.hoo', 'GET')
346 self.assertIsInstance(response, httplib2.Response) 353 self.assertIsInstance(response, httplib2.Response)
347 self.assertEqual(response.status, 404) 354 self.assertEqual(response.status, 404)
348 self.assertEqual(body, '') 355 self.assertEqual(body, '')
349 356
350 self.assertEqual(http.requests_made[0].uri, 'https://mywebserver.woo.hoo') 357 self.assertEqual(http.requests_made[0].uri, 'https://mywebserver.woo.hoo')
351 self.assertEqual(http.requests_made[0].method, 'GET') 358 self.assertEqual(http.requests_made[0].method, 'GET')
352 self.assertEqual(http.requests_made[0].body, None) 359 self.assertEqual(http.requests_made[0].body, None)
353 self.assertEqual(http.requests_made[0].headers, None) 360 self.assertEqual(http.requests_made[0].headers, None)
OLDNEW
« no previous file with comments | « infra_libs/httplib2_utils.py ('k') | infra_libs/ts_mon/common/monitors.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698