Пример #1
0
def test_get_expected_target_repoids_fallback(monkeypatch):
    """
    Test for the RepoMapDataHandler.get_expected_target_repoids method.

    Verifies that the RepoMapDataHandler.get_expected_target_repoids method is able to produce a correct
    map that maps target pesid to the best candidate pesid repository when there is a repository
    on the source system that does not have exact match equivalent and some other with a fallback channel
    must be found.
    """
    monkeypatch.setattr(
        api, 'current_actor',
        CurrentActorMocked(arch='x86_64', src_ver='7.9', dst_ver='8.4'))

    repositories_mapping = RepositoriesMapping(
        mapping=[RepoMapEntry(source='pesid1', target=['pesid2'])],
        repositories=[
            make_pesid_repo('pesid1', '7', 'pesid1-repoid-eus', channel='eus'),
            make_pesid_repo('pesid2', '8', 'pesid2-repoid-ga'),
            make_pesid_repo('pesid1', '8', 'pesid2-repoid-e4s', channel='e4s'),
        ])

    fail_description = (
        'The get_expected_target_repoids failed to find repository with a failback channel '
        'since there were no exact target equivalents.')

    handler = RepoMapDataHandler(repositories_mapping)
    handler.set_default_channels(['ga'])
    target_repoids = handler.get_expected_target_pesid_repos(
        ['pesid1-repoid-eus'])

    assert {
        'pesid2': repositories_mapping.repositories[1]
    } == target_repoids, fail_description
Пример #2
0
def test_find_repository_equivalent_with_priority_channel(monkeypatch):
    """
    Tests whether the _find_repository_target_equivalent correctly respects the chosen preferred channel.
    """
    envars = {'LEAPP_DEVEL_TARGET_PRODUCT_TYPE': 'eus'}

    monkeypatch.setattr(
        api, 'current_actor',
        CurrentActorMocked(arch='x86_64',
                           src_ver='7.9',
                           dst_ver='8.4',
                           envars=envars))
    repositories_mapping = RepositoriesMapping(
        mapping=[RepoMapEntry(source='pesid1', target=['pesid2'])],
        repositories=[
            make_pesid_repo('pesid1', '7', 'pesid1-repoid-ga'),
            make_pesid_repo('pesid2', '8', 'pesid2-repoid-ga', channel='ga'),
            make_pesid_repo('pesid2', '8', 'pesid2-repoid-eus', channel='eus'),
        ])

    handler = RepoMapDataHandler(repositories_mapping)
    handler.set_default_channels(['ga'])

    assert handler.prio_channel == 'eus'

    fail_description = '_find_repository_target_equivalent does not correcly respect preferred channel.'
    expected_target_equivalent = repositories_mapping.repositories[2]
    actual_target_equivalent = handler._find_repository_target_equivalent(
        repositories_mapping.repositories[0], 'pesid2')
    assert expected_target_equivalent == actual_target_equivalent, fail_description
Пример #3
0
def test_find_repository_target_equivalent_fallback_to_default(
        monkeypatch, mapping_data_for_find_repository_equiv):
    """
    Test for the RepoMapDataHandler._find_repository_target_equivalent method.

    Verifies that the method will find a target equivalent with matchin some of the fallback
    channels if a target equivalent that matches the source pesid repository completely is not
    available in the repository mapping data.
    """
    monkeypatch.setattr(
        api, 'current_actor',
        CurrentActorMocked(arch='x86_64', src_ver='7.9', dst_ver='8.4'))

    handler = RepoMapDataHandler(mapping_data_for_find_repository_equiv)
    repositories = mapping_data_for_find_repository_equiv.repositories

    fail_description = (
        'The _find_repository_target_equivalent failed to find repository with some of the fallback channels.'
    )
    expected_target_equivalent = repositories[6]
    actual_target_equivalent = handler._find_repository_target_equivalent(
        repositories[1], 'pesid2')
    assert expected_target_equivalent == actual_target_equivalent, fail_description

    handler.set_default_channels(['eus', 'ga'])

    expected_target_equivalent = repositories[7]
    actual_target_equivalent = handler._find_repository_target_equivalent(
        repositories[1], 'pesid2')
    assert expected_target_equivalent == actual_target_equivalent, fail_description
Пример #4
0
def test_get_expected_target_pesid_repos_with_priority_channel_set(
        monkeypatch):
    """
    Tests whether the get_expected_target_peid_repos correctly respects the chosen preferred channel.
    """

    envars = {'LEAPP_DEVEL_TARGET_PRODUCT_TYPE': 'eus'}

    monkeypatch.setattr(
        api, 'current_actor',
        CurrentActorMocked(arch='x86_64',
                           src_ver='7.9',
                           dst_ver='8.4',
                           envars=envars))

    repositories_mapping = RepositoriesMapping(
        mapping=[RepoMapEntry(source='pesid1', target=['pesid2', 'pesid3'])],
        repositories=[
            make_pesid_repo('pesid1', '7', 'pesid1-repoid-ga'),
            make_pesid_repo('pesid2', '8', 'pesid2-repoid-ga'),
            make_pesid_repo('pesid2', '8', 'pesid2-repoid-eus', channel='eus'),
            make_pesid_repo('pesid2', '8', 'pesid2-repoid-tuv', channel='tuv'),
            make_pesid_repo('pesid3', '8', 'pesid3-repoid-ga')
        ])

    handler = RepoMapDataHandler(repositories_mapping)
    # Set defaults to verify that the priority channel is not overwritten by defaults
    handler.set_default_channels(['tuv', 'ga'])
    target_repoids = handler.get_expected_target_pesid_repos(
        ['pesid1-repoid-ga'])

    fail_description = 'get_expected_target_peid_repos does not correcly respect preferred channel.'
    assert {
        'pesid2': repositories_mapping.repositories[2],
        'pesid3': repositories_mapping.repositories[4]
    } == target_repoids, fail_description