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

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

Issue 2844203002: [fetch] add tests for fetch subcommand parsing. (Closed)
Patch Set: rebase Created 3 years, 7 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/fetch.py ('k') | 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 # 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 itertools 7 import itertools
8 import json 8 import json
9 import unittest 9 import unittest
10 10
11 from cStringIO import StringIO
12
11 import test_env 13 import test_env
12 14
15 import argparse # this is vendored
16
13 import mock 17 import mock
14 import subprocess42 18 import subprocess42
15 19
20 from recipe_engine import common_args
16 from recipe_engine import fetch 21 from recipe_engine import fetch
17 from recipe_engine import package_pb2 22 from recipe_engine import package_pb2
18 from recipe_engine import requests_ssl 23 from recipe_engine import requests_ssl
19 24
20 25
21 CPE = subprocess42.CalledProcessError 26 CPE = subprocess42.CalledProcessError
22 27
23 28
24 class NoMoreExpectatedCalls(ValueError): 29 class NoMoreExpectatedCalls(ValueError):
25 pass 30 pass
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 self.j('repo/+/%s?name-status=1&format=JSON' % self.a, self.a_dat), 449 self.j('repo/+/%s?name-status=1&format=JSON' % self.a, self.a_dat),
445 self.d('repo/+/%s/infra/config/recipes.cfg?format=TEXT' % self.a, 450 self.d('repo/+/%s/infra/config/recipes.cfg?format=TEXT' % self.a,
446 self.proto_text), 451 self.proto_text),
447 ) 452 )
448 453
449 result = fetch.GitilesBackend('dir', 'repo', True).commit_metadata( 454 result = fetch.GitilesBackend('dir', 'repo', True).commit_metadata(
450 'revision') 455 'revision')
451 self.assertEqual(result, self.a_meta) 456 self.assertEqual(result, self.a_meta)
452 self.assertMultiDone(requests_get) 457 self.assertMultiDone(requests_get)
453 458
459
460 class TestArgs(unittest.TestCase):
461 def setUp(self):
462 self.p = argparse.ArgumentParser()
463 self.followup = common_args.add_common_args(self.p)
464 subp = self.p.add_subparsers()
465 fetch.add_subparser(subp)
466
467 @mock.patch('argparse._sys.stderr', new_callable=StringIO)
468 def test_no_fetch(self, stderr):
469 with self.assertRaises(SystemExit):
470 args = self.p.parse_args(['--no-fetch', 'fetch'])
471 args.postprocess_func(self.p, args)
472 self.assertIn('--no-fetch does not make sense', stderr.getvalue())
473
474
454 if __name__ == '__main__': 475 if __name__ == '__main__':
455 unittest.main() 476 unittest.main()
OLDNEW
« no previous file with comments | « recipe_engine/fetch.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698