Index: build/android/pylib/utils/md5sum_test.py |
diff --git a/build/android/pylib/utils/md5sum_test.py b/build/android/pylib/utils/md5sum_test.py |
index 6821c0ff659ee3fcbc5d079722a97621c913f111..e60b810254c4be86d13d8038b0dee8887ce40dab 100755 |
--- a/build/android/pylib/utils/md5sum_test.py |
+++ b/build/android/pylib/utils/md5sum_test.py |
@@ -93,12 +93,13 @@ class Md5SumTest(unittest.TestCase): |
] |
device.RunShellCommand = mock.Mock(return_value=device_md5sum_output) |
- out = md5sum.CalculateDeviceMd5Sums(test_path, device) |
- self.assertEquals(1, len(out)) |
- self.assertTrue('/storage/emulated/legacy/test/file.dat' in out) |
- self.assertEquals('0123456789abcdeffedcba9876543210', |
- out['/storage/emulated/legacy/test/file.dat']) |
- self.assertEquals(1, len(device.RunShellCommand.call_args_list)) |
+ with mock.patch('os.path.getsize', return_value=1337): |
+ out = md5sum.CalculateDeviceMd5Sums(test_path, device) |
+ self.assertEquals(1, len(out)) |
+ self.assertTrue('/storage/emulated/legacy/test/file.dat' in out) |
+ self.assertEquals('0123456789abcdeffedcba9876543210', |
+ out['/storage/emulated/legacy/test/file.dat']) |
+ self.assertEquals(1, len(device.RunShellCommand.call_args_list)) |
def testCalculateDeviceMd5Sums_list(self): |
test_path = ['/storage/emulated/legacy/test/file0.dat', |
@@ -112,15 +113,16 @@ class Md5SumTest(unittest.TestCase): |
] |
device.RunShellCommand = mock.Mock(return_value=device_md5sum_output) |
- out = md5sum.CalculateDeviceMd5Sums(test_path, device) |
- self.assertEquals(2, len(out)) |
- self.assertTrue('/storage/emulated/legacy/test/file0.dat' in out) |
- self.assertEquals('0123456789abcdeffedcba9876543210', |
- out['/storage/emulated/legacy/test/file0.dat']) |
- self.assertTrue('/storage/emulated/legacy/test/file1.dat' in out) |
- self.assertEquals('123456789abcdef00fedcba987654321', |
- out['/storage/emulated/legacy/test/file1.dat']) |
- self.assertEquals(1, len(device.RunShellCommand.call_args_list)) |
+ with mock.patch('os.path.getsize', return_value=1337): |
+ out = md5sum.CalculateDeviceMd5Sums(test_path, device) |
+ self.assertEquals(2, len(out)) |
+ self.assertTrue('/storage/emulated/legacy/test/file0.dat' in out) |
+ self.assertEquals('0123456789abcdeffedcba9876543210', |
+ out['/storage/emulated/legacy/test/file0.dat']) |
+ self.assertTrue('/storage/emulated/legacy/test/file1.dat' in out) |
+ self.assertEquals('123456789abcdef00fedcba987654321', |
+ out['/storage/emulated/legacy/test/file1.dat']) |
+ self.assertEquals(1, len(device.RunShellCommand.call_args_list)) |
def testCalculateDeviceMd5Sums_generator(self): |
test_path = ('/storage/emulated/legacy/test/file%d.dat' % n |
@@ -135,15 +137,16 @@ class Md5SumTest(unittest.TestCase): |
] |
device.RunShellCommand = mock.Mock(return_value=device_md5sum_output) |
- out = md5sum.CalculateDeviceMd5Sums(test_path, device) |
- self.assertEquals(2, len(out)) |
- self.assertTrue('/storage/emulated/legacy/test/file0.dat' in out) |
- self.assertEquals('0123456789abcdeffedcba9876543210', |
- out['/storage/emulated/legacy/test/file0.dat']) |
- self.assertTrue('/storage/emulated/legacy/test/file1.dat' in out) |
- self.assertEquals('123456789abcdef00fedcba987654321', |
- out['/storage/emulated/legacy/test/file1.dat']) |
- self.assertEquals(1, len(device.RunShellCommand.call_args_list)) |
+ with mock.patch('os.path.getsize', return_value=1337): |
+ out = md5sum.CalculateDeviceMd5Sums(test_path, device) |
+ self.assertEquals(2, len(out)) |
+ self.assertTrue('/storage/emulated/legacy/test/file0.dat' in out) |
+ self.assertEquals('0123456789abcdeffedcba9876543210', |
+ out['/storage/emulated/legacy/test/file0.dat']) |
+ self.assertTrue('/storage/emulated/legacy/test/file1.dat' in out) |
+ self.assertEquals('123456789abcdef00fedcba987654321', |
+ out['/storage/emulated/legacy/test/file1.dat']) |
+ self.assertEquals(1, len(device.RunShellCommand.call_args_list)) |
def testCalculateDeviceMd5Sums_singlePath_linkerWarning(self): |
# See crbug/479966 |
@@ -159,12 +162,13 @@ class Md5SumTest(unittest.TestCase): |
] |
device.RunShellCommand = mock.Mock(return_value=device_md5sum_output) |
- out = md5sum.CalculateDeviceMd5Sums(test_path, device) |
- self.assertEquals(1, len(out)) |
- self.assertTrue('/storage/emulated/legacy/test/file.dat' in out) |
- self.assertEquals('0123456789abcdeffedcba9876543210', |
- out['/storage/emulated/legacy/test/file.dat']) |
- self.assertEquals(1, len(device.RunShellCommand.call_args_list)) |
+ with mock.patch('os.path.getsize', return_value=1337): |
+ out = md5sum.CalculateDeviceMd5Sums(test_path, device) |
+ self.assertEquals(1, len(out)) |
+ self.assertTrue('/storage/emulated/legacy/test/file.dat' in out) |
+ self.assertEquals('0123456789abcdeffedcba9876543210', |
+ out['/storage/emulated/legacy/test/file.dat']) |
+ self.assertEquals(1, len(device.RunShellCommand.call_args_list)) |
def testCalculateDeviceMd5Sums_list_fileMissing(self): |
test_path = ['/storage/emulated/legacy/test/file0.dat', |
@@ -178,12 +182,13 @@ class Md5SumTest(unittest.TestCase): |
] |
device.RunShellCommand = mock.Mock(return_value=device_md5sum_output) |
- out = md5sum.CalculateDeviceMd5Sums(test_path, device) |
- self.assertEquals(1, len(out)) |
- self.assertTrue('/storage/emulated/legacy/test/file0.dat' in out) |
- self.assertEquals('0123456789abcdeffedcba9876543210', |
- out['/storage/emulated/legacy/test/file0.dat']) |
- self.assertEquals(1, len(device.RunShellCommand.call_args_list)) |
+ with mock.patch('os.path.getsize', return_value=1337): |
+ out = md5sum.CalculateDeviceMd5Sums(test_path, device) |
+ self.assertEquals(1, len(out)) |
+ self.assertTrue('/storage/emulated/legacy/test/file0.dat' in out) |
+ self.assertEquals('0123456789abcdeffedcba9876543210', |
+ out['/storage/emulated/legacy/test/file0.dat']) |
+ self.assertEquals(1, len(device.RunShellCommand.call_args_list)) |
def testCalculateDeviceMd5Sums_requiresBinary(self): |
@@ -203,14 +208,15 @@ class Md5SumTest(unittest.TestCase): |
device.RunShellCommand = mock.Mock( |
side_effect=(error, device_md5sum_output)) |
- out = md5sum.CalculateDeviceMd5Sums(test_path, device) |
- self.assertEquals(1, len(out)) |
- self.assertTrue('/storage/emulated/legacy/test/file.dat' in out) |
- self.assertEquals('0123456789abcdeffedcba9876543210', |
- out['/storage/emulated/legacy/test/file.dat']) |
- self.assertEquals(2, len(device.RunShellCommand.call_args_list)) |
- device.adb.Push.assert_called_once_with( |
- 'test/out/directory/md5sum_dist', '/data/local/tmp/md5sum/') |
+ with mock.patch('os.path.getsize', return_value=1337): |
+ out = md5sum.CalculateDeviceMd5Sums(test_path, device) |
+ self.assertEquals(1, len(out)) |
+ self.assertTrue('/storage/emulated/legacy/test/file.dat' in out) |
+ self.assertEquals('0123456789abcdeffedcba9876543210', |
+ out['/storage/emulated/legacy/test/file.dat']) |
+ self.assertEquals(2, len(device.RunShellCommand.call_args_list)) |
+ device.adb.Push.assert_called_once_with( |
+ 'test/out/directory/md5sum_dist', '/data/local/tmp/md5sum/') |
if __name__ == '__main__': |