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

Unified Diff: build/android/pylib/utils/device_temp_file_test.py

Issue 2392643003: Removes files from //build that we don't need (Closed)
Patch Set: Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « build/android/pylib/utils/device_temp_file.py ('k') | build/android/pylib/utils/emulator.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/pylib/utils/device_temp_file_test.py
diff --git a/build/android/pylib/utils/device_temp_file_test.py b/build/android/pylib/utils/device_temp_file_test.py
deleted file mode 100755
index f839ce093ca81e5f8dcda0faa7440653312ed2d7..0000000000000000000000000000000000000000
--- a/build/android/pylib/utils/device_temp_file_test.py
+++ /dev/null
@@ -1,91 +0,0 @@
-#!/usr/bin/env python
-# Copyright 2014 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-"""
-Unit tests for the contents of device_temp_file.py.
-"""
-
-import logging
-import os
-import sys
-import unittest
-
-from pylib import constants
-from pylib.device import adb_wrapper
-from pylib.device import device_errors
-from pylib.utils import device_temp_file
-from pylib.utils import mock_calls
-
-sys.path.append(os.path.join(
- constants.DIR_SOURCE_ROOT, 'third_party', 'pymock'))
-import mock # pylint: disable=F0401
-
-class DeviceTempFileTest(mock_calls.TestCase):
-
- def setUp(self):
- test_serial = '0123456789abcdef'
- self.adb = mock.Mock(spec=adb_wrapper.AdbWrapper)
- self.adb.__str__ = mock.Mock(return_value=test_serial)
- self.watchMethodCalls(self.call.adb)
-
- def mockShellCall(self, cmd_prefix, action=''):
- """Expect an adb.Shell(cmd) call with cmd_prefix and do some action
-
- Args:
- cmd_prefix: A string, the cmd of the received call is expected to have
- this as a prefix.
- action: If callable, an action to perform when the expected call is
- received, otherwise a return value.
- Returns:
- An (expected_call, action) pair suitable for use in assertCalls.
- """
- def check_and_return(cmd):
- self.assertTrue(
- cmd.startswith(cmd_prefix),
- 'command %r does not start with prefix %r' % (cmd, cmd_prefix))
- if callable(action):
- return action(cmd)
- else:
- return action
- return (self.call.adb.Shell(mock.ANY), check_and_return)
-
- def mockExistsTest(self, exists_result):
- def action(cmd):
- if exists_result:
- return ''
- else:
- raise device_errors.AdbCommandFailedError(
- cmd, 'File not found', 1, str(self.adb))
- return self.mockShellCall('test -e ', action)
-
- def testTempFileNameAlreadyExists(self):
- with self.assertCalls(
- self.mockShellCall('test -d /data/local/tmp'),
- self.mockExistsTest(True),
- self.mockExistsTest(True),
- self.mockExistsTest(True),
- self.mockExistsTest(False),
- self.mockShellCall('touch '),
- self.mockShellCall('rm -f ')):
- with device_temp_file.DeviceTempFile(self.adb) as tmpfile:
- logging.debug('Temp file name: %s' % tmpfile.name)
-
- def testTempFileLifecycle(self):
- with self.assertCalls(
- self.mockShellCall('test -d /data/local/tmp'),
- self.mockExistsTest(False),
- self.mockShellCall('touch ')):
- tempFileContextManager = device_temp_file.DeviceTempFile(self.adb)
- with mock.patch.object(self.adb, 'Shell'):
- with tempFileContextManager as tmpfile:
- logging.debug('Temp file name: %s' % tmpfile.name)
- self.assertEquals(0, self.adb.Shell.call_count)
- self.assertEquals(1, self.adb.Shell.call_count)
- args, _ = self.adb.Shell.call_args
- self.assertTrue(args[0].startswith('rm -f '))
-
-if __name__ == '__main__':
- logging.getLogger().setLevel(logging.DEBUG)
- unittest.main(verbosity=2)
« no previous file with comments | « build/android/pylib/utils/device_temp_file.py ('k') | build/android/pylib/utils/emulator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698