def test_start(self): mock = MagicMock(return_value=0) with patch.dict(debian_service.__salt__, {"cmd.retcode": mock}): # Test successful command (0 retcode) assert debian_service.start("foo") # Confirm expected command was run mock.assert_called_once_with("service foo start") # Test unsuccessful command (nonzero retcode) mock.return_value = 1 assert not debian_service.start("foo")
def test_start(self): ''' Test for Start the specified service ''' mock = MagicMock(return_value=True) with patch.object(debian_service, '_service_cmd', mock): with patch.dict(debian_service.__salt__, {'cmd.retcode': mock}): self.assertFalse(debian_service.start('name'))
def test_start(self): """ Test for Start the specified service """ mock = MagicMock(return_value=True) with patch.object(debian_service, "_service_cmd", mock): with patch.dict(debian_service.__salt__, {"cmd.retcode": mock}): self.assertFalse(debian_service.start("name"))