def test_upgrade(self): ''' Test if it upgrade all of the packages to the latest available version. ''' mock_run = MagicMock(return_value='A\t B\t SAME') mock_ret = MagicMock(return_value=0) mock_pkg = MagicMock(return_value='') with patch.dict(pkgutil.__salt__, {'cmd.run_stdout': mock_run, 'cmd.retcode': mock_ret, 'pkg_resource.stringify': mock_pkg, 'pkg_resource.sort_pkglist': mock_pkg, 'cmd.run_all': mock_ret, 'cmd.run': mock_run}): with patch.dict(pkgutil.__context__, {'pkg.list_pkgs': mock_ret}): self.assertDictEqual(pkgutil.upgrade(), {})
def test_upgrade(): """ Test if it upgrade all of the packages to the latest available version. """ mock_run = MagicMock(return_value="A\t B\t SAME") mock_ret = MagicMock(return_value=0) mock_pkg = MagicMock(return_value="") with patch.dict( pkgutil.__salt__, { "cmd.run_stdout": mock_run, "cmd.retcode": mock_ret, "pkg_resource.stringify": mock_pkg, "pkg_resource.sort_pkglist": mock_pkg, "cmd.run_all": mock_ret, "cmd.run": mock_run, }, ): with patch.dict(pkgutil.__context__, {"pkg.list_pkgs": mock_ret}): with patch.object(salt.utils.pkg, "clear_rtag", Mock()): assert pkgutil.upgrade() == {}