| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2013 The LUCI Authors. All rights reserved. | 2 # Copyright 2013 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 # pylint: disable=R0201 | 6 # pylint: disable=R0201 |
| 7 | 7 |
| 8 import StringIO | 8 import StringIO |
| 9 import base64 | 9 import base64 |
| 10 import contextlib | 10 import contextlib |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 subdir: [ | 421 subdir: [ |
| 422 {'package': pkg, 'instance_id': ver} | 422 {'package': pkg, 'instance_id': ver} |
| 423 for pkg, ver in packages | 423 for pkg, ver in packages |
| 424 ] | 424 ] |
| 425 for subdir, packages in pins.iteritems() | 425 for subdir, packages in pins.iteritems() |
| 426 } | 426 } |
| 427 }, json_out) | 427 }, json_out) |
| 428 return 0 | 428 return 0 |
| 429 | 429 |
| 430 self.popen_mocks.append(fake_ensure) | 430 self.popen_mocks.append(fake_ensure) |
| 431 self._fake_isolated_cache = {} |
| 432 self.mock(cipd.CipdClient, '_ensure_from_isolate', self.fake_ensure_from_iso
late) |
| 433 self.mock(cipd.CipdClient, '_isolate_cipd', self.fake_isolate_cipd) |
| 434 |
| 431 cipd_cache = os.path.join(self.tempdir, 'cipd_cache') | 435 cipd_cache = os.path.join(self.tempdir, 'cipd_cache') |
| 436 |
| 432 cmd = [ | 437 cmd = [ |
| 433 '--no-log', | 438 '--no-log', |
| 434 '--cache', os.path.join(self.tempdir, 'cache'), | 439 '--cache', os.path.join(self.tempdir, 'cache'), |
| 435 '--cipd-client-version', 'git:wowza', | 440 '--cipd-client-version', 'git:wowza', |
| 436 '--cipd-package', 'bin:infra/tools/echo/${platform}:latest', | 441 '--cipd-package', 'bin:infra/tools/echo/${platform}:latest', |
| 437 '--cipd-package', '.:infra/data/x:latest', | 442 '--cipd-package', '.:infra/data/x:latest', |
| 438 '--cipd-package', '.:infra/data/y:canary', | 443 '--cipd-package', '.:infra/data/y:canary', |
| 439 '--cipd-server', self.cipd_server.url, | 444 '--cipd-server', self.cipd_server.url, |
| 440 '--cipd-cache', cipd_cache, | 445 '--cipd-cache', cipd_cache, |
| 441 '--named-cache-root', os.path.join(self.tempdir, 'c'), | 446 '--named-cache-root', os.path.join(self.tempdir, 'c'), |
| (...skipping 29 matching lines...) Expand all Loading... |
| 471 cipd_cache, 'clients', 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')) | 476 cipd_cache, 'clients', 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')) |
| 472 self.assertTrue(fs.isfile(client_binary_file)) | 477 self.assertTrue(fs.isfile(client_binary_file)) |
| 473 | 478 |
| 474 # Test echo call. | 479 # Test echo call. |
| 475 echo_cmd, _ = self.popen_calls[1] | 480 echo_cmd, _ = self.popen_calls[1] |
| 476 self.assertTrue(echo_cmd[0].endswith( | 481 self.assertTrue(echo_cmd[0].endswith( |
| 477 os.path.sep + 'bin' + os.path.sep + 'echo' + cipd.EXECUTABLE_SUFFIX), | 482 os.path.sep + 'bin' + os.path.sep + 'echo' + cipd.EXECUTABLE_SUFFIX), |
| 478 echo_cmd[0]) | 483 echo_cmd[0]) |
| 479 self.assertEqual(echo_cmd[1:], ['hello', 'world']) | 484 self.assertEqual(echo_cmd[1:], ['hello', 'world']) |
| 480 | 485 |
| 486 def fake_ensure_from_isolate(self, target_dir, cipd_isolated, isolate_cache): |
| 487 # Not seen first time, then seen all other times |
| 488 if cipd_isolated not in self._fake_isolated_cache: |
| 489 self._fake_isolated_cache[cipd_isolated] = True |
| 490 return False |
| 491 return True |
| 492 |
| 493 def fake_isolate_cipd(self, root, pkgs, isolate_cache, cipd_cache): |
| 494 pass |
| 495 |
| 481 def test_main_naked_with_cipd_client_no_packages(self): | 496 def test_main_naked_with_cipd_client_no_packages(self): |
| 482 cipd_cache = os.path.join(self.tempdir, 'cipd_cache') | 497 cipd_cache = os.path.join(self.tempdir, 'cipd_cache') |
| 483 cmd = [ | 498 cmd = [ |
| 484 '--no-log', | 499 '--no-log', |
| 485 '--cache', os.path.join(self.tempdir, 'cache'), | 500 '--cache', os.path.join(self.tempdir, 'cache'), |
| 486 '--cipd-enabled', | 501 '--cipd-enabled', |
| 487 '--cipd-client-version', 'git:wowza', | 502 '--cipd-client-version', 'git:wowza', |
| 488 '--cipd-server', self.cipd_server.url, | 503 '--cipd-server', self.cipd_server.url, |
| 489 '--cipd-cache', cipd_cache, | 504 '--cipd-cache', cipd_cache, |
| 490 '--named-cache-root', os.path.join(self.tempdir, 'c'), | 505 '--named-cache-root', os.path.join(self.tempdir, 'c'), |
| (...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 985 self.assertEqual(expected, actual) | 1000 self.assertEqual(expected, actual) |
| 986 | 1001 |
| 987 | 1002 |
| 988 if __name__ == '__main__': | 1003 if __name__ == '__main__': |
| 989 fix_encoding.fix_encoding() | 1004 fix_encoding.fix_encoding() |
| 990 if '-v' in sys.argv: | 1005 if '-v' in sys.argv: |
| 991 unittest.TestCase.maxDiff = None | 1006 unittest.TestCase.maxDiff = None |
| 992 logging.basicConfig( | 1007 logging.basicConfig( |
| 993 level=logging.DEBUG if '-v' in sys.argv else logging.ERROR) | 1008 level=logging.DEBUG if '-v' in sys.argv else logging.ERROR) |
| 994 unittest.main() | 1009 unittest.main() |
| OLD | NEW |