def testRebootFailure(self, mock_fastboot_commands):
     mock_error = self.TestError()
     mock_error.stderr = self.TEST_MESSAGE_FAILURE
     mock_fastboot_commands.side_effect = mock_error
     device = fastbootsh.FastbootDevice(self.TEST_SERIAL)
     with self.assertRaises(fastboot_exceptions.FastbootFailure) as e:
         device.Reboot()
     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 = fastbootsh.FastbootDevice(self.TEST_SERIAL)
     message = device.Download(command)
     mock_fastboot_commands.assert_called_once_with('-s', self.TEST_SERIAL,
                                                    'stage', command)
     self.assertEqual(self.TEST_MESSAGE_SUCCESS, message)
 def testGetVar(self, mock_fastboot_commands):
     mock_fastboot_commands.return_value = self.TEST_VAR + ': ' + 'abcd'
     device = fastbootsh.FastbootDevice(self.TEST_SERIAL)
     message = device.GetVar(self.TEST_VAR)
     mock_fastboot_commands.assert_called_once_with('-s',
                                                    self.TEST_SERIAL,
                                                    'getvar',
                                                    self.TEST_VAR,
                                                    _err_to_out=True)
     self.assertEqual('abcd', message)
 def testOem(self, mock_fastboot_commands):
     mock_fastboot_commands.return_value = self.TEST_MESSAGE_SUCCESS
     command = 'TEST COMMAND'
     device = fastbootsh.FastbootDevice(self.TEST_SERIAL)
     message = device.Oem(command, False)
     mock_fastboot_commands.assert_called_once_with('-s',
                                                    self.TEST_SERIAL,
                                                    'oem',
                                                    command,
                                                    _err_to_out=False)
     self.assertEqual(self.TEST_MESSAGE_SUCCESS, message)
 def testReboot(self, mock_fastboot_commands):
     device = fastbootsh.FastbootDevice(self.TEST_SERIAL)
     device.Reboot()
     mock_fastboot_commands.assert_called_once_with('-s', self.TEST_SERIAL,
                                                    'reboot-bootloader')