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

Side by Side Diff: recipe_engine/unittests/fetch_test.py

Issue 2771723006: [recipes.cfg] ONLY support jsonpb. (Closed)
Patch Set: remove comment Created 3 years, 9 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 | « recipe_engine/package.py ('k') | unittests/errors_test.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 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2016 The LUCI Authors. All rights reserved. 2 # Copyright 2016 The LUCI Authors. All rights reserved.
3 # Use of this source code is governed under the Apache License, Version 2.0 3 # Use of this source code is governed under the Apache License, Version 2.0
4 # that can be found in the LICENSE file. 4 # that can be found in the LICENSE file.
5 5
6 import base64 6 import base64
7 import json 7 import json
8 import unittest 8 import unittest
9 9
10 import test_env 10 import test_env
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 class TestGitiles(unittest.TestCase): 185 class TestGitiles(unittest.TestCase):
186 def setUp(self): 186 def setUp(self):
187 requests_ssl.disable_check() 187 requests_ssl.disable_check()
188 188
189 @mock.patch('__builtin__.open', mock.mock_open()) 189 @mock.patch('__builtin__.open', mock.mock_open())
190 @mock.patch('shutil.rmtree') 190 @mock.patch('shutil.rmtree')
191 @mock.patch('os.makedirs') 191 @mock.patch('os.makedirs')
192 @mock.patch('tarfile.open') 192 @mock.patch('tarfile.open')
193 @mock.patch('requests.get') 193 @mock.patch('requests.get')
194 def test_checkout(self, requests_get, tarfile_open, makedirs, rmtree): 194 def test_checkout(self, requests_get, tarfile_open, makedirs, rmtree):
195 proto_text = u""" 195 proto_text = u"""{
196 api_version: 1 196 "api_version": 1,
197 project_id: "foo" 197 "project_id": "foo",
198 recipes_path: "path/to/recipes" 198 "recipes_path": "path/to/recipes"
199 """.lstrip() 199 }""".lstrip()
200 requests_get.side_effect = [ 200 requests_get.side_effect = [
201 mock.Mock(text=u')]}\'\n{ "commit": "abc123" }', status_code=200), 201 mock.Mock(text=u')]}\'\n{ "commit": "abc123" }', status_code=200),
202 mock.Mock(text=base64.b64encode(proto_text), status_code=200), 202 mock.Mock(text=base64.b64encode(proto_text), status_code=200),
203 mock.Mock(content='', status_code=200), 203 mock.Mock(content='', status_code=200),
204 ] 204 ]
205 205
206 fetch.GitilesBackend().checkout( 206 fetch.GitilesBackend().checkout(
207 'repo', 'revision', 'dir', allow_fetch=True) 207 'repo', 'revision', 'dir', allow_fetch=True)
208 208
209 requests_get.assert_has_calls([ 209 requests_get.assert_has_calls([
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 'author': 'author', 340 'author': 'author',
341 'message': 'message', 341 'message': 'message',
342 }) 342 })
343 self.assertEqual(counts['sleeps'], 4) 343 self.assertEqual(counts['sleeps'], 4)
344 requests_get.assert_has_calls([ 344 requests_get.assert_has_calls([
345 mock.call('repo/+/revision?format=JSON'), 345 mock.call('repo/+/revision?format=JSON'),
346 ] * 5) 346 ] * 5)
347 347
348 if __name__ == '__main__': 348 if __name__ == '__main__':
349 unittest.main() 349 unittest.main()
OLDNEW
« no previous file with comments | « recipe_engine/package.py ('k') | unittests/errors_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698