def test_upgrade_available(): """ Test if there is an upgrade available for a certain package. """ mock = MagicMock(return_value="A\n B\n SAME") with patch.dict(pkgutil.__salt__, {"cmd.run_stdout": mock}): assert pkgutil.upgrade_available("CSWpython") == "" mock = MagicMock(side_effect=["A\n B\n SALT", None]) with patch.dict(pkgutil.__salt__, {"cmd.run_stdout": mock}): assert pkgutil.upgrade_available("CSWpython") == "SALT" assert pkgutil.upgrade_available("CSWpython") == ""
def test_upgrade_available(self): ''' Test if there is an upgrade available for a certain package. ''' mock = MagicMock(return_value='A\n B\n SAME') with patch.dict(pkgutil.__salt__, {'cmd.run_stdout': mock}): self.assertEqual(pkgutil.upgrade_available('CSWpython'), '') mock = MagicMock(side_effect=['A\n B\n SALT', None]) with patch.dict(pkgutil.__salt__, {'cmd.run_stdout': mock}): self.assertEqual(pkgutil.upgrade_available('CSWpython'), 'SALT') self.assertEqual(pkgutil.upgrade_available('CSWpython'), '')