コード例 #1
0
ファイル: rh_service_test.py プロジェクト: bryson/salt
    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'))
コード例 #2
0
ファイル: rh_service_test.py プロジェクト: lvg01/salt.old
    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'))
コード例 #3
0
    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"))