Exemple #1
0
def test_get_output_from_action_defined(echo_cmd, expected_output):
    packit_repository_base = PackitRepositoryBase(
        config=flexmock(Config()),
        package_config=flexmock(PackageConfig(actions={ActionName.pre_sync: echo_cmd})),
    )

    packit_repository_base.local_project = flexmock(working_dir=".")

    result = packit_repository_base.get_output_from_action(ActionName.pre_sync)
    assert result == expected_output
Exemple #2
0
def test_base_push_good(upstream_distgit_remote):
    _, distgit, _ = upstream_distgit_remote
    b = PackitRepositoryBase(config=Config(), package_config=PackageConfig())
    b.local_project = LocalProject(
        working_dir=str(distgit),
        git_url="https://github.com/packit-service/lol")
    flexmock(
        LocalProject,
        push=lambda *args, **kwargs:
        [PushInfo(PushInfo.FAST_FORWARD, None, None, None, None)],
    )
    b.push("master")
Exemple #3
0
def packit_repository_base_with_sandcastle_object(tmp_path):
    c = Config()
    c.command_handler = RunCommandType.sandcastle
    b = PackitRepositoryBase(
        config=c,
        package_config=PackageConfig(
            actions={
                ActionName.pre_sync: "command -a",
                ActionName.get_current_version: "command -b",
            }),
    )
    b.local_project = LocalProject(working_dir=tmp_path)
    return b
Exemple #4
0
def test_get_output_from_action_defined():
    echo_cmd = "echo 'hello world'"

    packit_repository_base = PackitRepositoryBase(
        config=flexmock(),
        package_config=flexmock(
            PackageConfig(actions={ActionName.pre_sync: echo_cmd})),
    )

    packit_repository_base.local_project = flexmock(working_dir=".")

    result = packit_repository_base.get_output_from_action(ActionName.pre_sync)
    assert result == "hello world\n"
Exemple #5
0
def test_base_push_bad(upstream_distgit_remote):
    _, distgit, _ = upstream_distgit_remote
    b = PackitRepositoryBase(config=Config(), package_config=PackageConfig())
    b.local_project = LocalProject(
        working_dir=str(distgit),
        git_url="https://github.com/packit-service/lol")
    flexmock(
        LocalProject,
        push=lambda *args, **kwargs:
        [PushInfo(PushInfo.REMOTE_REJECTED, None, None, None, None)],
    )
    with pytest.raises(PackitException) as e:
        b.push("master")
    assert "unable to push" in str(e.value)
Exemple #6
0
def test_get_output_from_action_defined_in_sandcastle():
    echo_cmd = "hello world"
    flexmock(Sandcastle).should_receive("get_api_client")
    flexmock(Sandcastle).should_receive("is_pod_already_deployed").and_return(True)
    c = Config()
    c.command_handler = RunCommandType.sandcastle
    packit_repository_base = PackitRepositoryBase(
        config=c, package_config=PackageConfig(actions={ActionName.pre_sync: echo_cmd})
    )
    packit_repository_base.local_project = LocalProject()

    flexmock(Sandcastle).should_receive("run")
    flexmock(Sandcastle).should_receive("exec").and_return(echo_cmd)
    result = packit_repository_base.get_output_from_action(ActionName.pre_sync)
    assert result == echo_cmd