def test_uninstall_prompt_works(self): flexmock(lang.Command).should_receive('run').and_return((True, True)).once() flexmock(dapicli).should_receive('get_installed_daps').and_return(self.installed_daps) flexmock(dapicli).should_receive('_get_dependencies_of').and_return([]) flexmock(dapicli).should_receive('_install_path').and_return('.') flexmock(os).should_receive('remove').and_return(None) assert dapicli.uninstall_dap('foo', True, __ui__='cli') == ['foo'] flexmock(lang.Command).should_receive('run').and_return((False, False)).once() with pytest.raises(DapiLocalError): dapicli.uninstall_dap('foo', True)
def test_uninstall_prompt_works(self, monkeypatch): inp = 'input' if six.PY3 else 'raw_input' monkeypatch.setattr(six.moves.builtins, inp, lambda x: 'y') # Putting 'y' on fake stdin flexmock(dapicli).should_receive('get_installed_daps').and_return(self.installed_daps) flexmock(dapicli).should_receive('_get_dependencies_of').and_return([]) flexmock(dapicli).should_receive('_install_path').and_return('.') flexmock(os).should_receive('remove').and_return(None) assert dapicli.uninstall_dap('foo', True) == ['foo'] monkeypatch.setattr(six.moves.builtins, inp, lambda x: 'n') # Putting 'n' on fake stdin with pytest.raises(DapiLocalError): dapicli.uninstall_dap('foo', True)
def test_uninstall_prompt_works(self): flexmock(lang.Command).should_receive('run').and_return( (True, True)).once() flexmock(dapicli).should_receive('get_installed_daps').and_return( self.installed_daps) flexmock(dapicli).should_receive('_get_dependencies_of').and_return([]) flexmock(dapicli).should_receive('_install_path').and_return('.') flexmock(os).should_receive('remove').and_return(None) assert dapicli.uninstall_dap('foo', True, __ui__='cli') == ['foo'] flexmock(lang.Command).should_receive('run').and_return( (False, False)).once() with pytest.raises(DapiLocalError): dapicli.uninstall_dap('foo', True)
def test_uninstall_prompt_works(self, confirm, result, monkeypatch): inp = "input" if six.PY3 else "raw_input" monkeypatch.setattr(six.moves.builtins, inp, lambda x: confirm) # Putting 'y' on fake stdin flexmock(dapicli).should_receive("get_installed_daps").and_return(self.installed_daps) flexmock(dapicli).should_receive("_get_dependencies_of").and_return([]) flexmock(dapicli).should_receive("_install_path").and_return(".") flexmock(os).should_receive("remove").and_return(None) assert dapicli.uninstall_dap("foo", True) == result
def run(cls, **kwargs): exs = [] for pkg in kwargs['package']: logger.info('Uninstalling {pkg}...'.format(pkg=pkg)) try: done = dapicli.uninstall_dap(pkg, confirm=kwargs['force']) if done: logger.info('{pkg} successfully uninstalled'.format(pkg=pkg)) except Exception as e: exs.append(str(e)) logger.error(str(e)) if exs: raise exceptions.ExecutionException('; '.join(exs))
def run(cls, **kwargs): exs = [] uninstalled = [] for pkg in kwargs['package']: if pkg in uninstalled: logger.info('DAP {pkg} already uninstalled'.format(pkg=pkg)) continue logger.info('Uninstalling DAP {pkg} ...'.format(pkg=pkg)) try: done = dapicli.uninstall_dap(pkg, confirm=kwargs['force']) if done: logger.info('DAPs {pkgs} successfully uninstalled'.format(pkgs=' '.join(done))) uninstalled += done except Exception as e: exs.append(str(e)) logger.error(str(e)) if exs: raise exceptions.ExecutionException('; '.join(exs))
def run(self): exs = [] uninstalled = [] for pkg in self.kwargs['package']: if pkg in uninstalled: logger.info('DAP {pkg} already uninstalled'.format(pkg=pkg)) continue logger.info('Uninstalling DAP {pkg} ...'.format(pkg=pkg)) try: done = dapicli.uninstall_dap(pkg, confirm=self.kwargs['force'], allpaths=self.kwargs['allpaths']) if done: logger.info('DAPs {pkgs} successfully uninstalled'.format(pkgs=' '.join(done))) uninstalled += done except exceptions.DapiError as e: exs.append(utils.exc_as_decoded_string(e)) logger.error(utils.exc_as_decoded_string(e)) if exs: raise exceptions.ExecutionException('; '.join(exs))
def run(self): exs = [] uninstalled = [] for pkg in self.kwargs['package']: if pkg in uninstalled: logger.info('DAP {pkg} already uninstalled'.format(pkg=pkg)) continue logger.info('Uninstalling DAP {pkg} ...'.format(pkg=pkg)) try: done = dapicli.uninstall_dap(pkg, confirm=self.kwargs['force'], allpaths=self.kwargs['allpaths'], __ui__=self.kwargs['__ui__']) if done: logger.info('DAPs {pkgs} successfully uninstalled'.format( pkgs=' '.join(done))) uninstalled += done except exceptions.DapiError as e: exs.append(utils.exc_as_decoded_string(e)) logger.error(utils.exc_as_decoded_string(e)) if exs: raise exceptions.ExecutionException('; '.join(exs))