Exemple #1
0
def test_srpm_empty_patch(mock_remote_functionality_sourcegit,
                          api_instance_source_git, ref):
    sg_path = Path(api_instance_source_git.upstream_local_project.working_dir)
    mock_spec_download_remote_s(sg_path, sg_path / "fedora", "0.1.0")

    api_instance_source_git.up.specfile.spec_content.section(
        "%package")[10:10] = (
            "Patch1: amarillo.patch",
            "Patch2: citra.patch",
            "Patch5: saaz.patch",
            "Patch8: malt.patch",
        )
    api_instance_source_git.up.specfile.save()

    create_history_with_empty_commit(sg_path)

    with cwd(sg_path):
        api_instance_source_git.create_srpm(upstream_ref=ref)

    srpm_path = list(sg_path.glob("beer-0.1.0-2.*.src.rpm"))[0]
    assert srpm_path.is_file()
    build_srpm(srpm_path)

    assert {x.name
            for x in sg_path.joinpath("fedora").glob("*.patch")} == {
                "amarillo.patch",
                "citra.patch",
                "saaz.patch",
                "malt.patch",
            }
    assert sg_path.joinpath("fedora", "saaz.patch").read_text() == ""
Exemple #2
0
def test_srpm_patch_non_conseq_indices(mock_remote_functionality_sourcegit,
                                       api_instance_source_git, ref):
    sg_path = Path(api_instance_source_git.upstream_local_project.working_dir)
    mock_spec_download_remote_s(sg_path, sg_path / "fedora", "0.1.0")

    api_instance_source_git.up.specfile.spec_content.section(
        "%package")[10:10] = (
            "Patch0: amarillo.patch",
            "Patch3: citra.patch",
            "Patch4: saaz.patch",
            "Patch5: malt.patch",
        )
    api_instance_source_git.up.specfile.save()

    create_history_with_empty_commit(sg_path)

    malt = sg_path.joinpath("malt")
    malt.write_text("Wheat\n")
    git_add_and_commit(directory=sg_path,
                       message="Weißbier! Summer is coming!")

    with cwd(sg_path):
        api_instance_source_git.create_srpm(upstream_ref=ref)

    # make sure the patch is inserted AFTER existing patches
    patches = api_instance_source_git.up.specfile.tags.filter(name="Patch*",
                                                              valid=None)
    last_patch = list(patches)[-1]
    assert last_patch.name == "Patch6"
    assert (os.path.basename(
        api_instance_source_git.up.specfile.get_applied_patches()[-1].path) ==
            "0004-Wei-bier-Summer-is-coming.patch")

    srpm_path = list(sg_path.glob("beer-0.1.0-2.*.src.rpm"))[0]
    assert srpm_path.is_file()
    build_srpm(srpm_path)

    assert {x.name
            for x in sg_path.joinpath("fedora").glob("*.patch")} == {
                "amarillo.patch",
                "citra.patch",
                "saaz.patch",
                "malt.patch",
                "0004-Wei-bier-Summer-is-coming.patch",
            }
    assert sg_path.joinpath("fedora", "saaz.patch").read_text() == ""
Exemple #3
0
def test_srpm_patch_non_conseq_indices(mock_remote_functionality_sourcegit,
                                       api_instance_source_git, ref):
    sg_path = Path(api_instance_source_git.upstream_local_project.working_dir)
    mock_spec_download_remote_s(sg_path, sg_path / DISTRO_DIR, "0.1.0")

    with api_instance_source_git.up.specfile.sections() as sections:
        sections.package[10:10] = (
            "Patch0: amarillo.patch",
            "Patch3: citra.patch",
            "Patch4: saaz.patch",
            "Patch5: malt.patch",
        )

    create_history_with_empty_commit(sg_path)

    malt = sg_path.joinpath("malt")
    malt.write_text("Wheat\n")
    git_add_and_commit(directory=sg_path,
                       message="Weißbier! Summer is coming!")

    with cwd(sg_path):
        api_instance_source_git.create_srpm(upstream_ref=ref)

    # make sure the patch is inserted AFTER existing patches
    with api_instance_source_git.up.specfile.patches() as patches:
        last_patch = patches[-1]
    assert last_patch.number == 6
    assert last_patch.filename == "0004-Wei-bier-Summer-is-coming.patch"

    srpm_path = list(sg_path.glob("beer-0.1.0-2.*.src.rpm"))[0]
    assert srpm_path.is_file()
    build_srpm(srpm_path)

    assert {x.name
            for x in sg_path.joinpath(DISTRO_DIR).glob("*.patch")} == {
                "amarillo.patch",
                "citra.patch",
                "saaz.patch",
                "malt.patch",
                "0004-Wei-bier-Summer-is-coming.patch",
            }
    assert sg_path.joinpath(DISTRO_DIR, "saaz.patch").read_text() == ""