Beispiel #1
0
    def test_installed(self):
        '''
        Test to verify that the specified python is installed with pyenv.
        '''
        name = 'python-2.7.6'

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

        with patch.dict(pyenv.__opts__, {'test': True}):
            comt = ('python 2.7.6 is set to be installed')
            ret.update({'comment': comt})
            self.assertDictEqual(pyenv.installed(name), ret)

        with patch.dict(pyenv.__opts__, {'test': False}):
            mock_f = MagicMock(side_effect=[False, False, True])
            mock_fa = MagicMock(side_effect=[False, True])
            mock_str = MagicMock(return_value='2.7.6')
            mock_lst = MagicMock(return_value=['2.7.6'])
            with patch.dict(pyenv.__salt__, {'pyenv.is_installed': mock_f,
                                             'pyenv.install': mock_fa,
                                             'pyenv.default': mock_str,
                                             'pyenv.versions': mock_lst}):
                comt = ('pyenv failed to install')
                ret.update({'comment': comt, 'result': False})
                self.assertDictEqual(pyenv.installed(name), ret)

                comt = ('Requested python exists.')
                ret.update({'comment': comt, 'result': True, 'default': True})
                self.assertDictEqual(pyenv.installed(name), ret)

                self.assertDictEqual(pyenv.installed(name), ret)
Beispiel #2
0
    def test_installed(self):
        '''
        Test to verify that the specified python is installed with pyenv.
        '''
        name = 'python-2.7.6'

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

        with patch.dict(pyenv.__opts__, {'test': True}):
            comt = ('python 2.7.6 is set to be installed')
            ret.update({'comment': comt})
            self.assertDictEqual(pyenv.installed(name), ret)

        with patch.dict(pyenv.__opts__, {'test': False}):
            mock_f = MagicMock(side_effect=[False, False, True])
            mock_fa = MagicMock(side_effect=[False, True])
            mock_str = MagicMock(return_value='2.7.6')
            mock_lst = MagicMock(return_value=['2.7.6'])
            with patch.dict(
                    pyenv.__salt__, {
                        'pyenv.is_installed': mock_f,
                        'pyenv.install': mock_fa,
                        'pyenv.default': mock_str,
                        'pyenv.versions': mock_lst
                    }):
                comt = ('pyenv failed to install')
                ret.update({'comment': comt, 'result': False})
                self.assertDictEqual(pyenv.installed(name), ret)

                comt = ('Requested python exists.')
                ret.update({'comment': comt, 'result': True, 'default': True})
                self.assertDictEqual(pyenv.installed(name), ret)

                self.assertDictEqual(pyenv.installed(name), ret)
def test_installed():
    """
    Test to verify that the specified python is installed with pyenv.
    """
    name = "python-2.7.6"

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

    with patch.dict(pyenv.__opts__, {"test": True}):
        comt = "python 2.7.6 is set to be installed"
        ret.update({"comment": comt})
        assert pyenv.installed(name) == ret

    with patch.dict(pyenv.__opts__, {"test": False}):
        mock_f = MagicMock(side_effect=[False, False, True])
        mock_fa = MagicMock(side_effect=[False, True])
        mock_str = MagicMock(return_value="2.7.6")
        mock_lst = MagicMock(return_value=["2.7.6"])
        with patch.dict(
                pyenv.__salt__,
            {
                "pyenv.is_installed": mock_f,
                "pyenv.install": mock_fa,
                "pyenv.default": mock_str,
                "pyenv.versions": mock_lst,
            },
        ):
            comt = "pyenv failed to install"
            ret.update({"comment": comt, "result": False})
            assert pyenv.installed(name) == ret

            comt = "Requested python exists."
            ret.update({"comment": comt, "result": True, "default": True})
            assert pyenv.installed(name) == ret

            assert pyenv.installed(name) == ret