Esempio n. 1
0
    def test_get_enabled(self):
        """
        Test if it return the enabled services. Use the ``limit``
        param to restrict results to services of that type.
        """
        with patch.object(rh_service, "_upstart_services", self._m_ret()):
            with patch.object(rh_service, "_upstart_is_enabled",
                              MagicMock(return_value=False)):
                self.assertListEqual(rh_service.get_enabled("upstart"), [])

        mock_run = MagicMock(return_value="salt stack")
        with patch.dict(rh_service.__salt__, {"cmd.run": mock_run}):
            with patch.object(rh_service, "_sysv_services", self._m_ret()):
                with patch.object(rh_service, "_sysv_is_enabled",
                                  self._m_bool()):
                    self.assertListEqual(rh_service.get_enabled("sysvinit"),
                                         RET)

                    with patch.object(rh_service, "_upstart_services",
                                      self._m_lst()):
                        with patch.object(
                                rh_service,
                                "_upstart_is_enabled",
                                MagicMock(return_value=True),
                        ):
                            self.assertListEqual(rh_service.get_enabled(), RET)
Esempio n. 2
0
    def test_get_enabled(self):
        '''
        Test if it return the enabled services. Use the ``limit``
        param to restrict results to services of that type.
        '''
        with patch.object(rh_service, '_upstart_services', self._m_ret()):
            with patch.object(rh_service, '_upstart_is_enabled', MagicMock(return_value=False)):
                self.assertListEqual(rh_service.get_enabled('upstart'), [])

        mock_run = MagicMock(return_value='salt stack')
        with patch.dict(rh_service.__salt__, {'cmd.run': mock_run}):
            with patch.object(rh_service, '_sysv_services', self._m_ret()):
                with patch.object(rh_service, '_sysv_is_enabled',
                                  self._m_bool()):
                    self.assertListEqual(rh_service.get_enabled('sysvinit'),
                                         RET)

                    with patch.object(rh_service, '_upstart_services', self._m_lst()):
                        with patch.object(rh_service, '_upstart_is_enabled', MagicMock(return_value=True)):
                            self.assertListEqual(rh_service.get_enabled(), RET)
Esempio n. 3
0
    def test_get_enabled(self):
        '''
        Test if it return the enabled services. Use the ``limit``
        param to restrict results to services of that type.
        '''
        with patch.object(rh_service, '_upstart_services', self._m_ret()):
            global HAS_UPSTART
            HAS_UPSTART = True
            self.assertListEqual(rh_service.get_enabled('upstart'), [])

        mock_run = MagicMock(return_value='salt stack')
        with patch.dict(rh_service.__salt__, {'cmd.run': mock_run}):
            with patch.object(rh_service, '_sysv_services', self._m_ret()):
                with patch.object(rh_service, '_sysv_is_enabled',
                                  self._m_bool()):
                    self.assertListEqual(rh_service.get_enabled('sysvinit'),
                                         RET)

                    with patch.object(rh_service, '_upstart_services',
                                      self._m_lst()):
                        HAS_UPSTART = True
                        self.assertListEqual(rh_service.get_enabled(), RET)