示例#1
0
 def test_service_list_parser(self):
     """
     Test for parser of rc-status results
     """
     # no services is enabled
     mock = MagicMock(return_value='')
     with patch.dict(gentoo_service.__salt__, {'cmd.run': mock}):
         self.assertFalse(gentoo_service.get_enabled())
     mock.assert_called_once_with('rc-update -v show')
示例#2
0
 def test_service_list_parser(self):
     '''
     Test for parser of rc-status results
     '''
     # no services is enabled
     mock = MagicMock(return_value='')
     with patch.dict(gentoo_service.__salt__, {'cmd.run': mock}):
         self.assertFalse(gentoo_service.get_enabled())
     mock.assert_called_once_with('rc-update -v show')
示例#3
0
 def test_service_list_parser(self):
     """
     Test for parser of rc-status results
     """
     # no services is enabled
     mock = MagicMock(return_value="")
     with patch.dict(gentoo_service.__salt__, {"cmd.run": mock}):
         self.assertFalse(gentoo_service.get_enabled())
     mock.assert_called_once_with("rc-update -v show")
示例#4
0
 def test_get_enabled_single_runlevel(self):
     '''
     Test for Return a list of service that are enabled on boot
     '''
     service_name = 'name'
     runlevels = ['default']
     mock = MagicMock(return_value=self.__services({service_name: runlevels}))
     with patch.dict(gentoo_service.__salt__, {'cmd.run': mock}):
         enabled_services = gentoo_service.get_enabled()
         self.assertTrue(service_name in enabled_services)
         self.assertEqual(enabled_services[service_name], runlevels)
示例#5
0
 def test_get_enabled_single_runlevel(self):
     """
     Test for Return a list of service that are enabled on boot
     """
     service_name = 'name'
     runlevels = ['default']
     mock = MagicMock(return_value=self.__services({service_name: runlevels}))
     with patch.dict(gentoo_service.__salt__, {'cmd.run': mock}):
         enabled_services = gentoo_service.get_enabled()
         self.assertTrue(service_name in enabled_services)
         self.assertEqual(enabled_services[service_name], runlevels)
示例#6
0
 def test_get_enabled_with_multiple_runlevels(self):
     '''
     Test for Return a list of service that are enabled on boot at more than one runlevel
     '''
     service_name = 'name'
     runlevels = ['non-default', 'default']
     mock = MagicMock(return_value=self.__services({service_name: runlevels}))
     with patch.dict(gentoo_service.__salt__, {'cmd.run': mock}):
         enabled_services = gentoo_service.get_enabled()
         self.assertTrue(service_name in enabled_services)
         self.assertEqual(enabled_services[service_name][0], runlevels[1])
         self.assertEqual(enabled_services[service_name][1], runlevels[0])
示例#7
0
 def test_get_enabled_with_multiple_runlevels(self):
     """
     Test for Return a list of service that are enabled on boot at more than one runlevel
     """
     service_name = 'name'
     runlevels = ['non-default', 'default']
     mock = MagicMock(return_value=self.__services({service_name: runlevels}))
     with patch.dict(gentoo_service.__salt__, {'cmd.run': mock}):
         enabled_services = gentoo_service.get_enabled()
         self.assertTrue(service_name in enabled_services)
         self.assertEqual(enabled_services[service_name][0], runlevels[1])
         self.assertEqual(enabled_services[service_name][1], runlevels[0])
示例#8
0
    def test_get_enabled_filters_out_disabled_services(self):
        '''
        Test for Return a list of service that are enabled on boot
        '''
        service_name = 'name'
        runlevels = ['default']
        disabled_service = 'disabled'
        service_list = self.__services({service_name: runlevels, disabled_service: []})

        mock = MagicMock(return_value=service_list)
        with patch.dict(gentoo_service.__salt__, {'cmd.run': mock}):
            enabled_services = gentoo_service.get_enabled()
            self.assertEqual(len(enabled_services), 1)
            self.assertTrue(service_name in enabled_services)
            self.assertEqual(enabled_services[service_name], runlevels)
示例#9
0
    def test_get_enabled_filters_out_disabled_services(self):
        """
        Test for Return a list of service that are enabled on boot
        """
        service_name = 'name'
        runlevels = ['default']
        disabled_service = 'disabled'
        service_list = self.__services({service_name: runlevels, disabled_service: []})

        mock = MagicMock(return_value=service_list)
        with patch.dict(gentoo_service.__salt__, {'cmd.run': mock}):
            enabled_services = gentoo_service.get_enabled()
            self.assertEqual(len(enabled_services), 1)
            self.assertTrue(service_name in enabled_services)
            self.assertEqual(enabled_services[service_name], runlevels)
示例#10
0
    def test_get_enabled_filters_out_disabled_services(self):
        """
        Test for Return a list of service that are enabled on boot
        """
        service_name = "name"
        runlevels = ["default"]
        disabled_service = "disabled"
        service_list = self.__services({
            service_name: runlevels,
            disabled_service: []
        })

        mock = MagicMock(return_value=service_list)
        with patch.dict(gentoo_service.__salt__, {"cmd.run": mock}):
            enabled_services = gentoo_service.get_enabled()
            self.assertEqual(len(enabled_services), 1)
            self.assertTrue(service_name in enabled_services)
            self.assertEqual(enabled_services[service_name], runlevels)