Example #1
0
def test_absent():
    """
    Test to ensures that the named command is not running.
    """
    name = "apache2"

    ret = {"name": name, "changes": {}, "result": None, "comment": ""}

    mock = MagicMock(return_value="")
    with patch.dict(process.__salt__, {"ps.pgrep": mock, "ps.pkill": mock}):
        with patch.dict(process.__opts__, {"test": True}):
            comt = "No matching processes running"
            ret.update({"comment": comt})
            assert process.absent(name) == ret

        with patch.dict(process.__opts__, {"test": False}):
            ret.update({"result": True})
            assert process.absent(name) == ret
Example #2
0
    def test_absent(self):
        '''
        Test to ensures that the named command is not running.
        '''
        name = 'apache2'

        ret = {'name': name, 'changes': {}, 'result': None, 'comment': ''}

        mock = MagicMock(return_value='')
        with patch.dict(process.__salt__, {
                'ps.pgrep': mock,
                'ps.pkill': mock
        }):
            with patch.dict(process.__opts__, {'test': True}):
                comt = ('No matching processes running')
                ret.update({'comment': comt})
                self.assertDictEqual(process.absent(name), ret)

            with patch.dict(process.__opts__, {'test': False}):
                ret.update({'result': True})
                self.assertDictEqual(process.absent(name), ret)