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

Side by Side Diff: dashboard/dashboard/services/request_test.py

Issue 3019553002: [pinpoint] Gerrit patch support. (Closed)
Patch Set: Example URL Created 3 years, 2 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
OLDNEW
1 # Copyright 2017 The Chromium Authors. All rights reserved. 1 # Copyright 2017 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 httplib 5 import httplib
6 import unittest 6 import unittest
7 7
8 import mock 8 import mock
9 9
10 from dashboard.services import request 10 from dashboard.services import request
(...skipping 18 matching lines...) Expand all
29 response = request.Request('https://example.com') 29 response = request.Request('https://example.com')
30 self._request.assert_called_once_with('https://example.com', method='GET') 30 self._request.assert_called_once_with('https://example.com', method='GET')
31 self.assertEqual(response, 'response') 31 self.assertEqual(response, 'response')
32 32
33 def testRequestJson(self): 33 def testRequestJson(self):
34 self._request.return_value = ({'status': '200'}, '"response"') 34 self._request.return_value = ({'status': '200'}, '"response"')
35 response = request.RequestJson('https://example.com') 35 response = request.RequestJson('https://example.com')
36 self._request.assert_called_once_with('https://example.com', method='GET') 36 self._request.assert_called_once_with('https://example.com', method='GET')
37 self.assertEqual(response, 'response') 37 self.assertEqual(response, 'response')
38 38
39 def testRequestJsonWithPrefix(self):
40 self._request.return_value = ({'status': '200'}, ')]}\'\n"response"')
41 response = request.RequestJson('https://example.com')
42 self._request.assert_called_once_with('https://example.com', method='GET')
43 self.assertEqual(response, 'response')
44
39 def testRequestWithBodyAndParameters(self): 45 def testRequestWithBodyAndParameters(self):
40 self._request.return_value = ({'status': '200'}, 'response') 46 self._request.return_value = ({'status': '200'}, 'response')
41 response = request.Request('https://example.com', 'POST', body='a string', 47 response = request.Request('https://example.com', 'POST', body='a string',
42 url_param_1='value_1', url_param_2='value_2') 48 url_param_1='value_1', url_param_2='value_2')
43 self._request.assert_called_once_with( 49 self._request.assert_called_once_with(
44 'https://example.com?url_param_1=value_1&url_param_2=value_2', 50 'https://example.com?url_param_1=value_1&url_param_2=value_2',
45 method='POST', body='"a string"', 51 method='POST', body='"a string"',
46 headers={'Content-Type': 'application/json'}) 52 headers={'Content-Type': 'application/json'})
47 self.assertEqual(response, 'response') 53 self.assertEqual(response, 'response')
48 54
(...skipping 25 matching lines...) Expand all
74 self.assertEqual(response, 'response') 80 self.assertEqual(response, 'response')
75 81
76 def testHttpExceptionSuccessOnRetry(self): 82 def testHttpExceptionSuccessOnRetry(self):
77 return_value = ({'status': '200'}, 'response') 83 return_value = ({'status': '200'}, 'response')
78 self._request.side_effect = httplib.HTTPException, return_value 84 self._request.side_effect = httplib.HTTPException, return_value
79 response = request.Request('https://example.com') 85 response = request.Request('https://example.com')
80 86
81 self._request.assert_called_with('https://example.com', method='GET') 87 self._request.assert_called_with('https://example.com', method='GET')
82 self.assertEqual(self._request.call_count, 2) 88 self.assertEqual(self._request.call_count, 2)
83 self.assertEqual(response, 'response') 89 self.assertEqual(response, 'response')
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698