Esempio n. 1
0
def test_latest_version():
    """
    Test if it return the latest version of the named package
    available for upgrade or installation.
    """
    assert pkgutil.latest_version() == ""

    mock_run_all = MagicMock(return_value="A\t B\t SAME")
    mock_run = MagicMock(return_value={"stdout": ""})
    mock_ret = MagicMock(return_value=True)
    mock_pkg = MagicMock(return_value="")
    with patch.dict(
            pkgutil.__salt__,
        {
            "cmd.retcode": mock_ret,
            "pkg_resource.stringify": mock_pkg,
            "pkg_resource.sort_pkglist": mock_pkg,
            "cmd.run_all": mock_run,
            "cmd.run": mock_run_all,
        },
    ):
        with patch.object(salt.utils.pkg, "clear_rtag", Mock()):
            assert pkgutil.latest_version("CSWpython") == ""

            assert pkgutil.latest_version("CSWpython", "Python") == {
                "Python": "",
                "CSWpython": "",
            }
Esempio n. 2
0
    def test_latest_version(self):
        '''
        Test if it return the latest version of the named package
        available for upgrade or installation.
        '''
        self.assertEqual(pkgutil.latest_version(), '')

        mock_run_all = MagicMock(return_value='A\t B\t SAME')
        mock_run = MagicMock(return_value={'stdout': ''})
        mock_ret = MagicMock(return_value=True)
        mock_pkg = MagicMock(return_value='')
        with patch.dict(
                pkgutil.__salt__, {
                    'cmd.retcode': mock_ret,
                    'pkg_resource.stringify': mock_pkg,
                    'pkg_resource.sort_pkglist': mock_pkg,
                    'cmd.run_all': mock_run,
                    'cmd.run': mock_run_all
                }):
            self.assertEqual(pkgutil.latest_version('CSWpython'), '')

            self.assertDictEqual(pkgutil.latest_version('CSWpython', 'Python'),
                                 {
                                     'Python': '',
                                     'CSWpython': ''
                                 })
Esempio n. 3
0
    def test_latest_version(self):
        '''
        Test if it return the latest version of the named package
        available for upgrade or installation.
        '''
        self.assertEqual(pkgutil.latest_version(), '')

        mock_run_all = MagicMock(return_value='A\t B\t SAME')
        mock_run = MagicMock(return_value={'stdout': ''})
        mock_ret = MagicMock(return_value=True)
        mock_pkg = MagicMock(return_value='')
        with patch.dict(pkgutil.__salt__,
                        {'cmd.retcode': mock_ret,
                         'pkg_resource.stringify': mock_pkg,
                         'pkg_resource.sort_pkglist': mock_pkg,
                         'cmd.run_all': mock_run, 'cmd.run': mock_run_all}):
            self.assertEqual(pkgutil.latest_version('CSWpython'), '')

            self.assertDictEqual(pkgutil.latest_version('CSWpython', 'Python'),
                                 {'Python': '', 'CSWpython': ''})