def test_yum_rollback_manager(): minion_id = os.environ['TEST_MINION_ID'] some_minion_id = 'some_minion_id' with pytest.raises(errors.SaltNoReturnError) as excinfo: with YumRollbackManager(some_minion_id) as rb_manager: pass with pytest.raises(ValueError) as excinfo: with YumRollbackManager(minion_id) as rb_manager: assert minion_id in rb_manager.last_txn_ids cmd_run('yum install -y vim', minion_id) cmd_run('rpm -qi vim-enhanced', minion_id) raise ValueError('some error') assert str(excinfo.value) == 'some error' with pytest.raises(errors.SaltError): cmd_run('rpm -qi vim-enhanced', minion_id)
def _enter(*args, **kwargs): YumRollbackManager.__enter__(*args, **kwargs) return mocker.DEFAULT
def _exit(*args, **kwargs): YumRollbackManager.__exit__(*args, **kwargs) return mocker.DEFAULT
def _init(self, *args, **kwargs): for k, v in attr.asdict(YumRollbackManager(*args, **kwargs)).items(): setattr(self, k, v) return mocker.DEFAULT