Пример #1
0
def test_get_action_associate(klass, method):
    mocked_unit_1 = MagicMock()
    mocked_unit_1.associate_source_repo_id = "test_src_1"
    mocked_unit_2 = MagicMock()
    mocked_unit_2.associate_source_repo_id = "test_src_2"
    units = [mocked_unit_1, mocked_unit_2]
    dst_repo = Repo("test_dst", "1", "test_dst-rpms", "2", "2", "2", None,
                    None, None)
    src_repos = [
        Repo("test_src_1", "1", "test_src-rpms", "2", "2", "2", None, None,
             None),
        Repo("test_src_2", "1", "test_src-rpms", "2", "2", "2", None, None,
             None)
    ]
    action = klass(units, dst_repo, src_repos)
    actions = action.get_actions(MagicMock())
    for action in actions:
        associate_action, src_repo_current, dst_repo_current, current_units = action
        assert "mock." + method in str(associate_action)
        assert len(current_units) == 1
        assert current_units == [
            u for u in units
            if u.associate_source_repo_id == src_repo_current.repo_id
        ]
        assert dst_repo_current.repo_id == dst_repo.repo_id
        assert src_repo_current.repo_id == current_units[
            0].associate_source_repo_id
Пример #2
0
def test_get_action_associate(klass, method):
    units = ["unit1", "unit2"]
    dst_repo = Repo("test_dst", "1", "test_dst-rpms", "2", None, None)
    src_repo = Repo("test_src", "1", "test_src-rpms", "2", None, None)
    action = klass(units, dst_repo, src_repo)
    associate_action, src_repo_current, dst_repo_current, current_units = \
        action.get_action(MagicMock())

    assert "mock." + method in str(associate_action)
    assert current_units == units
    assert dst_repo_current.repo_id == dst_repo.repo_id
    assert src_repo_current.repo_id == src_repo.repo_id
def get_test_repo(**kwargs):
    return Repo(
        kwargs.get('repo_id'),
        kwargs.get('arch'),
        kwargs.get('platform_full_version'),
        kwargs.get('distributors_ids_type_ids'),
    )
Пример #4
0
def fixture_mock_repo():
    yield Repo(
        "test_repo",
        "x86_64",
        "7",
        [
            ("dist_id_1", "dist_type_id_1"),
            ("dist_id_2", "dist_type_id_2"),
        ],
    )
Пример #5
0
def fixture_mock_repo():
    yield Repo(
        repo_id="test_repo",
        arch="x86_64",
        content_set="test_repo-source-rpms",
        platform_full_version="7",
        dist_ids_type_ids=[
            ("dist_id_1", "dist_type_id_1"),
            ("dist_id_2", "dist_type_id_2"),
        ],
        ubi_population=None,
    )
Пример #6
0
def test_raise_not_implemented_associate_action():
    units = ["unit1", "unit2"]
    repo = Repo("test", "1", "test-rpms", "2", "2", "2", None, None, None)
    src_repo = Repo("test", "1", "test-rpms", "2", "2", "2", None, None, None)
    action = AssociateAction(units, repo, src_repo)
    pytest.raises(NotImplementedError, action.get_actions, None)
Пример #7
0
def test_raise_not_implemented_pulp_action():
    units = ["unit1", "unit2"]
    repo = Repo("test", "1", "test-rpms", "2", "2", "2", None, None, None)
    action = PulpAction(units, repo)
    pytest.raises(NotImplementedError, action.get_actions, None)