def test_dead(self):
        ret = [{'changes': {}, 'comment': '', 'name': 'salt', 'result': True},
               {'changes': 'saltstack',
                'comment': 'The service salt is already dead', 'name': 'salt',
                'result': True},
               {'changes': {},
                'comment': 'Service salt is set to be killed', 'name': 'salt',
                'result': None},
               {'changes': 'saltstack',
                'comment': 'Service salt was killed', 'name': 'salt',
                'result': True},
               {'changes': {},
                'comment': 'Service salt was killed', 'name': 'salt',
                'result': True},
               {'changes': 'saltstack',
                'comment': 'The service salt is already dead', 'name': 'salt',
                'result': True}]

        mock = MagicMock(return_value="salt")
        with patch.object(service, '_enabled_used_error', mock):
            self.assertEqual(service.dead("salt", enabled=1), 'salt')

        tmock = MagicMock(return_value=True)
        fmock = MagicMock(return_value=False)
        with patch.object(service, '_available', fmock):
            self.assertDictEqual(service.dead("salt"), ret[0])

        with patch.object(service, '_available', tmock):
            mock = MagicMock(return_value={'changes': 'saltstack'})
            with contextlib.nested(
                patch.dict(service.__opts__, {'test': True}),
                patch.dict(
                    service.__salt__,
                    {'service.enabled': MagicMock(return_value=False),
                     'service.stop': MagicMock(return_value=True),
                     'service.status': MagicMock(return_value=False)}),
                patch.object(service, '_enable', mock)
            ):
                self.assertDictEqual(service.dead("salt", True), ret[5])
            with contextlib.nested(
                patch.dict(service.__opts__, {'test': False}),
                patch.dict(
                    service.__salt__,
                    {'service.enabled': MagicMock(return_value=False),
                     'service.stop': MagicMock(return_value=True),
                     'service.status': MagicMock(return_value=False)}),
                patch.object(service, '_enable', mock)
            ):
                self.assertDictEqual(service.dead("salt", True), ret[1])

            with contextlib.nested(
                patch.dict(service.__opts__, {'test': True}),
                patch.dict(
                    service.__salt__,
                    {'service.enabled': MagicMock(return_value=True),
                     'service.status': MagicMock(return_value=True)}),
            ):
                self.assertDictEqual(service.dead("salt"), ret[2])

            with contextlib.nested(
                patch.dict(service.__opts__, {'test': False}),
                patch.dict(
                    service.__salt__,
                    {'service.enabled':
                     MagicMock(side_effect=[True, True, False]),
                     'service.status':
                     MagicMock(side_effect=[True, True, False]),
                     'service.stop': MagicMock(return_value="stack")}),
                patch.object(
                    service, '_enable',
                    MagicMock(return_value={'changes': 'saltstack'}))
            ):
                self.assertDictEqual(service.dead("salt", True), ret[3])

            # test an initd which a wrong status (True even if dead)
            with contextlib.nested(
                patch.dict(service.__opts__, {'test': False}),
                patch.dict(
                    service.__salt__,
                    {'service.enabled':
                     MagicMock(side_effect=[False, False, False]),
                     'service.status':
                     MagicMock(side_effect=[True, True, True]),
                     'service.stop': MagicMock(return_value="stack")}),
                patch.object(
                    service, '_disable',
                    MagicMock(return_value={}))
            ):
                self.assertDictEqual(service.dead("salt", False), ret[4])
Test to ensure that the named service is dead
dataset/ETHPy150Open saltstack/salt/tests/unit/states/service_test.py/ServiceTestCase.test_dead