Exemplo n.º 1
0
def test_basic_local_update_using_distgit(cwd_upstream, api_instance,
                                          mock_remote_functionality_upstream):
    """basic propose-downstream test: mock remote API, use local upstream and dist-git"""
    u, d, api = api_instance
    mock_spec_download_remote_s(d)

    api.sync_release(dist_git_branch="main", version="0.1.0")

    assert (d / TARBALL_NAME).is_file()
    spec = Specfile(d / "beer.spec")
    assert spec.expanded_version == "0.1.0"

    with spec.sections() as sections:
        package_section = sections.package

    assert package_section[2] == "# some change"
    assert package_section[4] == "Name:           beer"
    assert package_section[5] == "Version:        0.1.0"
    assert package_section[6] == "Release:        1%{?dist}"
    assert package_section[7] == "Summary:        A tool to make you happy"

    assert (d / "README.packit").is_file()
    # assert that we have changelog entries for both versions
    with spec.sections() as sections:
        changelog = "\n".join(sections.changelog)
    assert "0.0.0" in changelog
    assert "0.1.0" in changelog
Exemplo n.º 2
0
def test_write_spec_content(specfile):
    data = "new line 1\n"
    spec = Specfile(specfile, autosave=True)
    with spec.sections() as sections:
        sections.description = [data]

    assert "new line 1" in specfile.read_text()
Exemplo n.º 3
0
def test_local_update_generated_spec(cwd_upstream, api_instance,
                                     mock_remote_functionality_upstream):
    """Check that specfile can be generated on clone."""
    u, d, api = api_instance
    mock_spec_download_remote_s(d)
    flexmock(api).should_receive("init_kerberos_ticket").at_least().once()
    flexmock(Upstream).should_receive(
        "get_latest_released_version").and_return("0.1.0")

    # Simulate generation by moving the spec to a different location
    # We are checking two things:
    # * spec-file is not used before the post-upstream-clone
    # * the version is get from the release state
    current_spec_location = u / "beer.spec"
    new_spec_location = u / ".." / "tmp.spec"
    shutil.move(current_spec_location, new_spec_location)
    subprocess.check_call(["git", "add", "beer.spec"], cwd=u)
    subprocess.check_call(
        ["git", "commit", "-m", "Spec removed from upstream"], cwd=u)
    api.up.package_config.actions = {
        ActionName.post_upstream_clone:
        [f"mv {new_spec_location} {current_spec_location}"]
    }

    api.sync_release(dist_git_branch="main")

    assert (d / TARBALL_NAME).is_file()
    spec = Specfile(d / "beer.spec")
    assert spec.expanded_version == "0.1.0"
    assert (d / "README.packit").is_file()
    # assert that we have changelog entries for both versions
    with spec.sections() as sections:
        changelog = "\n".join(sections.changelog)
    assert "0.0.0" in changelog
    assert "0.1.0" in changelog
Exemplo n.º 4
0
def test_basic_local_update_copy_upstream_release_description(
        cwd_upstream, api_instance, mock_remote_functionality_upstream):
    """basic propose-downstream test: mock remote API, use local upstream and dist-git,
    set copy_upstream_release_description in package config to True"""
    u, d, api = api_instance
    mock_spec_download_remote_s(d)
    flexmock(api).should_receive("init_kerberos_ticket").at_least().once()
    release = flexmock(body="Some description of the upstream release")
    api.up.local_project.git_project = flexmock(
        get_release=lambda name, tag_name: release)
    api.package_config.copy_upstream_release_description = True
    api.sync_release(dist_git_branch="main", version="0.1.0")

    assert (d / TARBALL_NAME).is_file()
    spec = Specfile(d / "beer.spec")
    assert spec.expanded_version == "0.1.0"
    assert (d / "README.packit").is_file()
    # assert that we have changelog entries for both versions
    with spec.sections() as sections:
        changelog = "\n".join(sections.changelog)

    assert ("""- 0.1.0-1
Some description of the upstream release
""" in changelog)

    assert "0.0.0" in changelog
    assert "0.1.0" in changelog
Exemplo n.º 5
0
    def set_specfile_content(
        self,
        specfile: Specfile,
        version: Optional[str] = None,
        comment: Optional[str] = None,
    ):
        """
        Update this specfile using provided specfile

        Args:
            specfile: specfile to get changes from (we update self.specfile)
            version: version to set in self.specfile
            comment: new comment for the version in %changelog
        """
        with self.specfile.sections() as sections, specfile.sections(
        ) as other_sections:
            try:
                previous_changelog = sections.changelog[:]
            except AttributeError:
                previous_changelog = []
            sections[:] = other_sections[:]
            try:
                sections.changelog = previous_changelog
            except AttributeError:
                sections.append(Section("changelog", previous_changelog))
        if version is not None:
            self.specfile.version = version
        if comment is not None:
            self.specfile.add_changelog_entry(comment)
Exemplo n.º 6
0
def test_basic_local_update(cwd_upstream, api_instance,
                            mock_remote_functionality_upstream):
    """basic propose-downstream test: mock remote API, use local upstream and dist-git"""
    u, d, api = api_instance
    mock_spec_download_remote_s(d)
    flexmock(api).should_receive("init_kerberos_ticket").at_least().once()

    api.sync_release(dist_git_branch="main", version="0.1.0")

    assert (d / TARBALL_NAME).is_file()
    spec = Specfile(d / "beer.spec")
    assert spec.expanded_version == "0.1.0"
    assert (d / "README.packit").is_file()
    # assert that we have changelog entries for both versions
    with spec.sections() as sections:
        changelog = "\n".join(sections.changelog)
    assert "0.0.0" in changelog
    assert "0.1.0" in changelog