Example #1
0
    def test_installed(self):
        '''
        Test to make sure that a pecl extension is installed.
        '''
        name = 'mongo'
        ver = '1.0.1'

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

        mock_lst = MagicMock(return_value={name: 'stable'})
        mock_t = MagicMock(return_value=True)
        with patch.dict(pecl.__salt__, {
                'pecl.list': mock_lst,
                'pecl.install': mock_t
        }):
            comt = ('Pecl extension {0} is already installed.'.format(name))
            ret.update({'comment': comt, 'result': True})
            self.assertDictEqual(pecl.installed(name), ret)

            with patch.dict(pecl.__opts__, {'test': True}):
                comt = ('Pecl extension mongo-1.0.1 would have been installed')
                ret.update({'comment': comt, 'result': None})
                self.assertDictEqual(pecl.installed(name, version=ver), ret)

            with patch.dict(pecl.__opts__, {'test': False}):
                comt = (
                    'Pecl extension mongo-1.0.1 was successfully installed')
                ret.update({
                    'comment': comt,
                    'result': True,
                    'changes': {
                        'mongo-1.0.1': 'Installed'
                    }
                })
                self.assertDictEqual(pecl.installed(name, version=ver), ret)
Example #2
0
def test_installed():
    """
    Test to make sure that a pecl extension is installed.
    """
    name = "mongo"
    ver = "1.0.1"

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

    mock_lst = MagicMock(return_value={name: "stable"})
    mock_t = MagicMock(return_value=True)
    with patch.dict(pecl.__salt__, {
            "pecl.list": mock_lst,
            "pecl.install": mock_t
    }):
        comt = "Pecl extension {} is already installed.".format(name)
        ret.update({"comment": comt, "result": True})
        assert pecl.installed(name) == ret

        with patch.dict(pecl.__opts__, {"test": True}):
            comt = "Pecl extension mongo-1.0.1 would have been installed"
            ret.update({"comment": comt, "result": None})
            assert pecl.installed(name, version=ver) == ret

        with patch.dict(pecl.__opts__, {"test": False}):
            comt = "Pecl extension mongo-1.0.1 was successfully installed"
            ret.update({
                "comment": comt,
                "result": True,
                "changes": {
                    "mongo-1.0.1": "Installed"
                },
            })
            assert pecl.installed(name, version=ver) == ret
Example #3
0
    def test_installed(self):
        """
        Test to make sure that a pecl extension is installed.
        """
        name = "mongo"
        ver = "1.0.1"

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

        mock_lst = MagicMock(return_value={name: "stable"})
        mock_t = MagicMock(return_value=True)
        with patch.dict(pecl.__salt__, {"pecl.list": mock_lst, "pecl.install": mock_t}):
            comt = "Pecl extension {0} is already installed.".format(name)
            ret.update({"comment": comt, "result": True})
            self.assertDictEqual(pecl.installed(name), ret)

            with patch.dict(pecl.__opts__, {"test": True}):
                comt = "Pecl extension mongo-1.0.1 would have been installed"
                ret.update({"comment": comt, "result": None})
                self.assertDictEqual(pecl.installed(name, version=ver), ret)

            with patch.dict(pecl.__opts__, {"test": False}):
                comt = "Pecl extension mongo-1.0.1 was successfully installed"
                ret.update({"comment": comt, "result": True, "changes": {"mongo-1.0.1": "Installed"}})
                self.assertDictEqual(pecl.installed(name, version=ver), ret)