def test_status(self): ''' Test if it return the status for a service, returns a bool whether the service is running. ''' with patch.object(rh_service, '_service_is_upstart', self._m_bool()): mock_run = MagicMock(return_value='start/running') with patch.dict(rh_service.__salt__, {'cmd.run': mock_run}): self.assertTrue(rh_service.status('salt-api')) with patch.object(rh_service, '_service_is_upstart', self._m_bool(False)): with patch.dict(rh_service.__salt__, {'status.pid': self._m_bool()}): self.assertTrue(rh_service.status('salt-api', sig=True)) mock_ret = MagicMock(return_value=0) with patch.dict(rh_service.__salt__, {'cmd.retcode': mock_ret}): self.assertTrue(rh_service.status('salt-api'))
def test_status(self): """ Test if it return the status for a service, returns a bool whether the service is running. """ with patch.object(rh_service, "_service_is_upstart", self._m_bool()): mock_run = MagicMock(return_value="start/running") with patch.dict(rh_service.__salt__, {"cmd.run": mock_run}): self.assertTrue(rh_service.status("salt-api")) with patch.object(rh_service, "_service_is_upstart", self._m_bool(False)): with patch.dict(rh_service.__salt__, {"status.pid": self._m_bool()}): self.assertTrue(rh_service.status("salt-api", sig=True)) mock_ret = MagicMock(return_value=0) with patch.dict(rh_service.__salt__, {"cmd.retcode": mock_ret}): self.assertTrue(rh_service.status("salt-api"))