| 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 """ | 6 """ |
| 7 Unit tests for the contents of device_temp_file.py. | 7 Unit tests for the contents of device_temp_file.py. |
| 8 """ | 8 """ |
| 9 | 9 |
| 10 import logging | 10 import logging |
| 11 import os | |
| 12 import sys | 11 import sys |
| 13 import unittest | 12 import unittest |
| 14 | 13 |
| 14 from devil import devil_env |
| 15 from devil.android import device_errors | 15 from devil.android import device_errors |
| 16 from devil.android import device_temp_file | 16 from devil.android import device_temp_file |
| 17 from devil.android.sdk import adb_wrapper | 17 from devil.android.sdk import adb_wrapper |
| 18 from devil.utils import mock_calls | 18 from devil.utils import mock_calls |
| 19 from pylib import constants | |
| 20 | 19 |
| 21 sys.path.append(os.path.join( | 20 sys.path.append(devil_env.config.pymock_path) |
| 22 constants.DIR_SOURCE_ROOT, 'third_party', 'pymock')) | |
| 23 import mock # pylint: disable=F0401 | 21 import mock # pylint: disable=F0401 |
| 24 | 22 |
| 25 class DeviceTempFileTest(mock_calls.TestCase): | 23 class DeviceTempFileTest(mock_calls.TestCase): |
| 26 | 24 |
| 27 def setUp(self): | 25 def setUp(self): |
| 28 test_serial = '0123456789abcdef' | 26 test_serial = '0123456789abcdef' |
| 29 self.adb = mock.Mock(spec=adb_wrapper.AdbWrapper) | 27 self.adb = mock.Mock(spec=adb_wrapper.AdbWrapper) |
| 30 self.adb.__str__ = mock.Mock(return_value=test_serial) | 28 self.adb.__str__ = mock.Mock(return_value=test_serial) |
| 31 self.watchMethodCalls(self.call.adb) | 29 self.watchMethodCalls(self.call.adb) |
| 32 | 30 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 with tempFileContextManager as tmpfile: | 80 with tempFileContextManager as tmpfile: |
| 83 logging.debug('Temp file name: %s', tmpfile.name) | 81 logging.debug('Temp file name: %s', tmpfile.name) |
| 84 self.assertEquals(0, self.adb.Shell.call_count) | 82 self.assertEquals(0, self.adb.Shell.call_count) |
| 85 self.assertEquals(1, self.adb.Shell.call_count) | 83 self.assertEquals(1, self.adb.Shell.call_count) |
| 86 args, _ = self.adb.Shell.call_args | 84 args, _ = self.adb.Shell.call_args |
| 87 self.assertTrue(args[0].startswith('rm -f ')) | 85 self.assertTrue(args[0].startswith('rm -f ')) |
| 88 | 86 |
| 89 if __name__ == '__main__': | 87 if __name__ == '__main__': |
| 90 logging.getLogger().setLevel(logging.DEBUG) | 88 logging.getLogger().setLevel(logging.DEBUG) |
| 91 unittest.main(verbosity=2) | 89 unittest.main(verbosity=2) |
| OLD | NEW |