def testGetVarFailure(self, mock_fastboot_commands):
     mock_error = TestError()
     mock_error.output = self.TEST_MESSAGE_FAILURE
     mock_fastboot_commands.side_effect = mock_error
     device = fastbootsubp.FastbootDevice(self.TEST_SERIAL)
     with self.assertRaises(fastboot_exceptions.FastbootFailure) as e:
         device.Reboot()
     self.assertEqual(self.TEST_MESSAGE_FAILURE, str(e.exception))
 def testDownloadFailure(self, mock_fastboot_commands):
     mock_error = TestError()
     mock_error.output = self.TEST_MESSAGE_FAILURE
     mock_fastboot_commands.side_effect = mock_error
     command = 'TEST COMMAND'
     device = fastbootsubp.FastbootDevice(self.TEST_SERIAL)
     with self.assertRaises(fastboot_exceptions.FastbootFailure) as e:
         device.Download(command)
     self.assertEqual(self.TEST_MESSAGE_FAILURE, str(e.exception))
 def testDownload(self, mock_fastboot_commands):
     mock_fastboot_commands.return_value = self.TEST_MESSAGE_SUCCESS
     command = 'TEST COMMAND'
     device = fastbootsubp.FastbootDevice(self.TEST_SERIAL)
     message = device.Download(command)
     mock_fastboot_commands.assert_called_once_with(
         ['fastboot', '-s', self.TEST_SERIAL, 'stage', command],
         creationflags=CREATE_NO_WINDOW)
     self.assertEqual(self.TEST_MESSAGE_SUCCESS, message)
 def testOemErrToOut(self, mock_fastboot_commands):
     mock_fastboot_commands.return_value = self.TEST_MESSAGE_SUCCESS
     command = 'TEST COMMAND'
     device = fastbootsubp.FastbootDevice(self.TEST_SERIAL)
     message = device.Oem(command, True)
     mock_fastboot_commands.assert_called_once_with(
         ['fastboot', '-s', self.TEST_SERIAL, 'oem', command],
         stderr=subprocess.STDOUT,
         creationflags=CREATE_NO_WINDOW)
     self.assertEqual(self.TEST_MESSAGE_SUCCESS, message)
 def testGetVar(self, mock_fastboot_commands):
     mock_fastboot_commands.return_value = (self.TEST_VAR + ': ' +
                                            self.TEST_MESSAGE)
     device = fastbootsubp.FastbootDevice(self.TEST_SERIAL)
     message = device.GetVar(self.TEST_VAR)
     mock_fastboot_commands.assert_called_once_with(
         ['fastboot', '-s', self.TEST_SERIAL, 'getvar', self.TEST_VAR],
         stderr=subprocess.STDOUT,
         shell=True,
         creationflags=CREATE_NO_WINDOW)
     self.assertEqual(self.TEST_MESSAGE, message)
 def testGetVar(self, mock_fastboot_commands):
     device = fastbootsubp.FastbootDevice(self.TEST_SERIAL)
     message = device.Reboot()
     mock_fastboot_commands.assert_called_once_with(
         ['fastboot', '-s', self.TEST_SERIAL, 'reboot-bootloader'],
         creationflags=CREATE_NO_WINDOW)