def test_gather_target_repositories_required_not_available(monkeypatch): # If the repos that Leapp identifies as required for the upgrade (based on the repo mapping and PES data) are not # available, an exception shall be raised monkeypatch.setattr(userspacegen.api, 'current_actor', CurrentActorMocked()) # The available RHSM repos monkeypatch.setattr(rhsm, 'get_available_repo_ids', lambda x: ['repoidA', 'repoidB', 'repoidC']) monkeypatch.setattr(rhsm, 'skip_rhsm', lambda: False) # The required RHEL repos based on the repo mapping and PES data + custom repos required by third party actors monkeypatch.setattr( userspacegen.api, 'consume', lambda x: iter([ models.TargetRepositories( rhel_repos=[ models.RHELTargetRepository(repoid='repoidX'), models.RHELTargetRepository(repoid='repoidY') ], custom_repos= [models.CustomTargetRepository(repoid='repoidCustom')]) ])) with pytest.raises(StopActorExecutionError) as err: userspacegen.gather_target_repositories(None) assert "Cannot find required basic RHEL 8 repositories" in str(err)
def test_gather_target_repositories(monkeypatch): monkeypatch.setattr(userspacegen.api, 'current_actor', CurrentActorMocked()) # The available RHSM repos monkeypatch.setattr(rhsm, 'get_available_repo_ids', lambda x: ['repoidX', 'repoidY', 'repoidZ']) monkeypatch.setattr(rhsm, 'skip_rhsm', lambda: False) # The required RHEL repos based on the repo mapping and PES data + custom repos required by third party actors monkeypatch.setattr(userspacegen.api, 'consume', lambda x: iter([models.TargetRepositories( rhel_repos=[models.RHELTargetRepository(repoid='repoidX'), models.RHELTargetRepository(repoid='repoidY')], custom_repos=[models.CustomTargetRepository(repoid='repoidCustom')])])) target_repoids = userspacegen.gather_target_repositories(None, None) assert target_repoids == ['repoidX', 'repoidY', 'repoidCustom']
def test_gather_target_repositories_rhui(monkeypatch): indata = testInData(_PACKAGES_MSGS, _RHSMINFO_MSG, _RHUIINFO_MSG, _XFS_MSG, _STORAGEINFO_MSG, None) monkeypatch.setattr(userspacegen.api, 'current_actor', CurrentActorMocked()) monkeypatch.setattr(userspacegen, '_get_all_available_repoids', lambda x: []) monkeypatch.setattr(userspacegen, '_get_rh_available_repoids', lambda x, y: ['rhui-1', 'rhui-2', 'rhui-3']) monkeypatch.setattr(rhsm, 'skip_rhsm', lambda: True) monkeypatch.setattr( userspacegen.api, 'consume', lambda x: iter([ models.TargetRepositories(rhel_repos=[ models.RHELTargetRepository(repoid='rhui-1'), models.RHELTargetRepository(repoid='rhui-2') ]) ])) target_repoids = userspacegen.gather_target_repositories(None, indata) assert target_repoids == set(['rhui-1', 'rhui-2'])
def test_gather_target_repositories_required_not_available(monkeypatch): # If the repos that Leapp identifies as required for the upgrade (based on the repo mapping and PES data) are not # available, an exception shall be raised mocked_produce = produce_mocked() monkeypatch.setattr(userspacegen.api, 'current_actor', CurrentActorMocked()) monkeypatch.setattr(userspacegen.api.current_actor(), 'produce', mocked_produce) # The available RHSM repos monkeypatch.setattr(rhsm, 'get_available_repo_ids', lambda x: ['repoidA', 'repoidB', 'repoidC']) monkeypatch.setattr(rhsm, 'skip_rhsm', lambda: False) # The required RHEL repos based on the repo mapping and PES data + custom repos required by third party actors monkeypatch.setattr( userspacegen.api, 'consume', lambda x: iter([ models.TargetRepositories( rhel_repos=[ models.RHELTargetRepository(repoid='repoidX'), models.RHELTargetRepository(repoid='repoidY') ], custom_repos= [models.CustomTargetRepository(repoid='repoidCustom')]) ])) with pytest.raises(StopActorExecution): userspacegen.gather_target_repositories(None) assert mocked_produce.called reports = [ m.report for m in mocked_produce.model_instances if isinstance(m, reporting.Report) ] inhibitors = [m for m in reports if 'INHIBITOR' in m.get('flags', ())] assert len(inhibitors) == 1 assert inhibitors[0].get( 'title', '') == 'Cannot find required basic RHEL target repositories.'