| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 import os | 6 import os |
| 7 import sys | 7 import sys |
| 8 import unittest | 8 import unittest |
| 9 | 9 |
| 10 from pylib import cmd_helper | 10 from pylib import cmd_helper |
| 11 from pylib import constants | 11 from pylib import constants |
| 12 from pylib.utils import md5sum | 12 from pylib.utils import md5sum |
| 13 | 13 |
| 14 sys.path.append( | 14 sys.path.append( |
| 15 os.path.join(constants.DIR_SOURCE_ROOT, 'third_party', 'pymock')) | 15 os.path.join(constants.DIR_SOURCE_ROOT, 'third_party', 'pymock')) |
| 16 import mock | 16 import mock |
| 17 | 17 |
| 18 TEST_OUT_DIR = os.path.join('test', 'out', 'directory') | 18 TEST_OUT_DIR = os.path.join('test', 'out', 'directory') |
| 19 HOST_MD5_EXECUTABLE = os.path.join(TEST_OUT_DIR, 'md5sum_bin_host') | 19 HOST_MD5_EXECUTABLE = os.path.join(TEST_OUT_DIR, 'md5sum_bin_host') |
| 20 | 20 |
| 21 class Md5SumTest(unittest.TestCase): | 21 class Md5SumTest(unittest.TestCase): |
| 22 | 22 |
| 23 def setUp(self): | 23 def setUp(self): |
| 24 self._patchers = [ | 24 self._patchers = [ |
| 25 mock.patch('pylib.constants.GetOutDirectory', | 25 mock.patch('pylib.constants.GetOutDirectory', |
| 26 new=mock.Mock(return_value=TEST_OUT_DIR)), | 26 new=mock.Mock(return_value=TEST_OUT_DIR)), |
| 27 mock.patch('os.path.exists', |
| 28 new=mock.Mock(return_value=True)), |
| 27 ] | 29 ] |
| 28 for p in self._patchers: | 30 for p in self._patchers: |
| 29 p.start() | 31 p.start() |
| 30 | 32 |
| 31 def tearDown(self): | 33 def tearDown(self): |
| 32 for p in self._patchers: | 34 for p in self._patchers: |
| 33 p.stop() | 35 p.stop() |
| 34 | 36 |
| 35 def testCalculateHostMd5Sums_singlePath(self): | 37 def testCalculateHostMd5Sums_singlePath(self): |
| 36 test_path = '/test/host/file.dat' | 38 test_path = '/test/host/file.dat' |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 out['/storage/emulated/legacy/test/file.dat']) | 221 out['/storage/emulated/legacy/test/file.dat']) |
| 220 device.adb.Push.assert_called_once_with( | 222 device.adb.Push.assert_called_once_with( |
| 221 '/tmp/test/script/file.sh', '/data/local/tmp/test/script/file.sh') | 223 '/tmp/test/script/file.sh', '/data/local/tmp/test/script/file.sh') |
| 222 device.RunShellCommand.assert_called_once_with( | 224 device.RunShellCommand.assert_called_once_with( |
| 223 ['sh', '/data/local/tmp/test/script/file.sh']) | 225 ['sh', '/data/local/tmp/test/script/file.sh']) |
| 224 | 226 |
| 225 | 227 |
| 226 if __name__ == '__main__': | 228 if __name__ == '__main__': |
| 227 unittest.main(verbosity=2) | 229 unittest.main(verbosity=2) |
| 228 | 230 |
| OLD | NEW |