def test_remove(self): """ Test - Remove packages. """ with patch("salt.modules.aptpkg._uninstall", MagicMock(return_value=UNINSTALL)): self.assertEqual(aptpkg.remove(name="tmux"), UNINSTALL)
def test_remove(uninstall_var): """ Test - Remove packages. """ with patch("salt.modules.aptpkg._uninstall", MagicMock(return_value=uninstall_var)): assert aptpkg.remove(name="tmux") == uninstall_var
def test_remove(self): ''' Test - Remove packages. ''' with patch('salt.modules.aptpkg._uninstall', MagicMock(return_value=UNINSTALL)): self.assertEqual(aptpkg.remove(name='tmux'), UNINSTALL)
def test_remove(self): ''' Test - Remove packages. ''' assert aptpkg.remove(name='tmux') == UNINSTALL
def test_remove(self): ''' Test - Remove packages. ''' self.assertEqual(aptpkg.remove(name='tmux'), UNINSTALL)
def test_owner(self): """ Test - Return the name of the package that owns the file. ''' assert aptpkg.owner('/usr/bin/wget') == 'wget' @patch('salt.utils.pkg.clear_rtag', MagicMock()) @patch('salt.modules.aptpkg.__salt__', {'cmd.run_all': MagicMock(return_value={'retcode': 0, 'stdout': APT_Q_UPDATE}), 'config.get': MagicMock(return_value=False)}) def test_refresh_db(self): """ Test - Updates the APT database to latest packages based upon repositories. """ refresh_db = { "http://security.ubuntu.com trusty-security InRelease": True, "http://security.ubuntu.com trusty-security/main Sources": True, "http://security.ubuntu.com trusty-security/main Translation-en": None, "http://security.ubuntu.com trusty-security/main amd64 Packages": True, "http://security.ubuntu.com trusty-security/main i386 Packages": True, } assert aptpkg.refresh_db() == refresh_db @patch('salt.utils.pkg.clear_rtag', MagicMock()) @patch('salt.modules.aptpkg.__salt__', {'cmd.run_all': MagicMock(return_value={'retcode': 0, 'stdout': APT_Q_UPDATE_ERROR}), 'config.get': MagicMock(return_value=False)}) def test_refresh_db_failed(self): """ Test - Update the APT database using unreachable repositories. ''' with pytest.raises(CommandExecutionError) as err: aptpkg.refresh_db(failhard=True) assert 'Error getting repos' in str(err) assert 'http://security.ubuntu.com trusty InRelease, http://security.ubuntu.com trusty Release.gpg' in str(err) def test_autoremove(self): """ Test - Remove packages not required by another package. """ with patch("salt.modules.aptpkg.list_pkgs", MagicMock(return_value=PACKAGES)): patch_kwargs = { "__salt__": { "config.get": MagicMock(return_value=True), "cmd.run_all": MagicMock( return_value=MagicMock(return_value=AUTOREMOVE) ), } } with patch.multiple(aptpkg, **patch_kwargs): assert aptpkg.autoremove() == {} assert aptpkg.autoremove(purge=True) == {} assert aptpkg.autoremove(list_only=True) == [] assert aptpkg.autoremove(list_only=True, purge=True) == [] @patch('salt.modules.aptpkg._uninstall', MagicMock(return_value=UNINSTALL)) def test_remove(self): """ Test - Remove packages. ''' assert aptpkg.remove(name='tmux') == UNINSTALL