def test_check_ready_should_raise_exception_if_multipule_bootloaders(self, mock_chmod, mock_stat, mock_isfile, mock_Popen): mock_Popen.return_value.communicate.return_value = ('"USB\VID_{0:04X}&PID_{1:04X}"\n"USB\VID_{0:04X}&PID_{1:04X}"'.format(self.BOOTLOADER_IDVENDOR, self.BOOTLOADER_IDPRODUCT), '') mock_Popen.return_value.wait.return_value = 0 fw_up = WindowsFirmwareUpdater('somepath', self.BOOTLOADER_IDVENDOR, self.BOOTLOADER_IDPRODUCT, self.PEACHY_IDVENDOR, self.PEACHY_IDPRODUCT) with self.assertRaises(Exception): fw_up.check_ready() mock_Popen.assert_called_with('''wmic.exe path WIN32_PnPEntity where "DeviceID like 'USB\\\\VID_%'" get HardwareID''', stdout=PIPE, stderr=PIPE)
def test_check_ready_should_return_False_if_only_peachy_results(self, mock_chmod, mock_stat, mock_isfile, mock_Popen): mock_Popen.return_value.communicate.return_value = ('"USB\VID_{:04X}&PID_{:04X}"'.format(self.PEACHY_IDVENDOR, self.PEACHY_IDPRODUCT), '') mock_Popen.return_value.wait.return_value = 0 fw_up = WindowsFirmwareUpdater('somepath', self.BOOTLOADER_IDVENDOR, self.BOOTLOADER_IDPRODUCT, self.PEACHY_IDVENDOR, self.PEACHY_IDPRODUCT) result = fw_up.check_ready() self.assertFalse(result) mock_Popen.assert_called_with('''wmic.exe path WIN32_PnPEntity where "DeviceID like 'USB\\\\VID_%'" get HardwareID''', stdout=PIPE, stderr=PIPE)