def testPingDD(self): """Test that UsbImagerOperation._PingDD() sends the correct signal.""" expected_cmd = ['kill', '-USR1', '5'] run_mock = self.PatchObject(cros_build_lib, 'SudoRunCommand') op = flash.UsbImagerOperation('foo') op._PingDD(5) # Check that SudoRunCommand was called correctly. run_mock.assert_called_with(expected_cmd, print_cmd=False)
def testGetDDPidNotFound(self): """Check that -1 is returned for _GetDDPid() if the pids aren't valid.""" expected_pid = -1 op = flash.UsbImagerOperation('foo') self.PatchObject(osutils, 'IsChildProcess', return_value=False) self.rc.AddCmdResult(partial_mock.Ignore(), output='5\n10\n') pid = op._GetDDPid() # Check that the correct pid was returned. self.assertEqual(pid, expected_pid)
def testGetDDPidFound(self): """Check that the expected pid is returned for _GetDDPid().""" expected_pid = 5 op = flash.UsbImagerOperation('foo') self.PatchObject(osutils, 'IsChildProcess', return_value=True) self.rc.AddCmdResult(partial_mock.Ignore(), output='%d\n10\n' % expected_pid) pid = op._GetDDPid() # Check that the correct pid was returned. self.assertEqual(pid, expected_pid)