diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 33c4ce8..fc90222 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -6,7 +6,7 @@ on: - main jobs: - test-cases: + test: runs-on: ubuntu-latest strategy: fail-fast: false @@ -21,9 +21,26 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | + sudo apt-get install -y git python -m pip install --upgrade pip python -m pip install poetry poetry install - name: Run tests run: | poetry run pytest -vvv test/ + + check-install: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-versions: ["3.9", "3.11"] + + steps: + - uses: actions/checkout@v3 + - name: Set up Python --version ${{ matrix.python-version }} + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} + - name: Test if alpa installs on Ubuntu + run: pip install . && alpa --help diff --git a/Containerfile b/Containerfile index 461d251..9bae7b8 100644 --- a/Containerfile +++ b/Containerfile @@ -1,6 +1,5 @@ # this containerfile is only for testing purposes - FROM fedora:latest # here will be the copied files from alpa @@ -10,6 +9,6 @@ COPY . /alpa/alpa_copy # bind local alpa project to this directory to tinker with it RUN mkdir -p /alpa/alpa_bind -RUN dnf install -y make git pip poetry +RUN dnf install -y make git pip poetry pytest # install package dependencies (first enter poetry shell -> `$ poetry shell`) RUN poetry install diff --git a/Makefile b/Makefile index cfc44ac..498a551 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,7 @@ IMAGE_NAME=alpa-test CONTAINER_ENGINE ?= $(shell command -v podman 2> /dev/null || echo docker) +# regenerate new image when needed build-image: $(CONTAINER_ENGINE) build --rm --tag $(IMAGE_NAME) -f Containerfile @@ -12,7 +13,7 @@ enter-image: check-tests: - poetry shell && pytest -vvv test/ + $(CONTAINER_ENGINE) run -ti $(IMAGE_NAME) bash -c "poetry run pytest -vvv test/" check-install: @@ -23,5 +24,7 @@ check-install: check: check-install check-tests -container-check: build-image - $(CONTAINER_ENGINE) run -ti $(IMAGE_NAME) make check +ci-check-install: build-image check-install + + +ci-check-tests: build-image check-tests diff --git a/alpa.spec b/alpa.spec index 5e52512..d843a39 100644 --- a/alpa.spec +++ b/alpa.spec @@ -1,5 +1,5 @@ Name: alpa -Version: 0.9.1 +Version: 0.10.0 Release: 1%{?dist} Summary: Integration tool with Alpa repository diff --git a/alpa/cli/local_repo.py b/alpa/cli/local_repo.py index c6cd3b5..c18ce46 100644 --- a/alpa/cli/local_repo.py +++ b/alpa/cli/local_repo.py @@ -52,13 +52,12 @@ def switch(name: str) -> None: default="", help="Your commit message not longer than 80 characters.", ) -@click.option("-n", "--no-verify", is_flag=True, help="Do not run pre-commit") -def commit(message: str, no_verify: bool) -> None: +def commit(message: str) -> None: """Commit your changes in your package's repository""" if len(message) > 80: raise ClickException("Message longer than 80 characters") - LocalRepoBranch(Path(getcwd())).commit(message, not no_verify) + LocalRepoBranch(Path(getcwd())).commit(message) @click.command("add") diff --git a/alpa/constants.py b/alpa/constants.py index e6cb3d3..a51c15e 100644 --- a/alpa/constants.py +++ b/alpa/constants.py @@ -37,15 +37,14 @@ ALPA_CONFIG_FILE_NAMES = [".alpa.yaml", ".alpa.yml", "alpa.yaml", "alpa.yml"] REQUEST_LABEL = "request" +CREATE_PACKAGE_REQUEST_TITLE = ( + "[alpa request-new-package] New request to create a package {package_name}" +) +DELETE_PACKAGE_REQUEST_TITLE = ( + "[alpa delete-package] New request to delete a package {package_name}" +) -class PackageRequest(str, Enum): - TITLE = "[alpa request-new-package] New request for package {package_name}" - BODY = "@{user} requested {package_name}" - LABEL = REQUEST_LABEL - - -class DeleteRequest(str, Enum): - TITLE = "[alpa delete-package] New request for deleting package {package_name}" - BODY = "@{user} requested to delete {package_name}" - LABEL = REQUEST_LABEL +class RequestEnum(str, Enum): + delete = "delete" + create = "create" diff --git a/alpa/repository/base.py b/alpa/repository/base.py index bd0b127..fbd029c 100644 --- a/alpa/repository/base.py +++ b/alpa/repository/base.py @@ -5,6 +5,7 @@ import logging import subprocess from abc import ABC, abstractmethod +from json import dumps from os import getcwd from pathlib import Path from typing import Optional, Iterable @@ -19,6 +20,10 @@ ALPA_FEAT_BRANCH_PREFIX, ORIGIN_NAME, UPSTREAM_NAME, + RequestEnum, + REQUEST_LABEL, + DELETE_PACKAGE_REQUEST_TITLE, + CREATE_PACKAGE_REQUEST_TITLE, ) from alpa.gh import GithubAPI, GithubRepo from alpa.git import GitCMD @@ -237,7 +242,7 @@ def branch_exists(self, branch: str) -> bool: def get_history_of_branch(self, branch: str, params: list[str]) -> str: return self.git_cmd(["log", "--decorate", "--graph"] + params + [branch]).stdout - def commit(self, message: str, pre_commit: bool) -> bool: + def commit(self, message: str) -> bool: packit_conf = Packit(self.package) if not packit_conf.packit_config_file_exists(): packit_conf.create_packit_config() @@ -321,13 +326,29 @@ def __init__(self, repo_path: Path, gh_api: Optional[GithubAPI] = None) -> None: def create_package(self, package: str) -> None: pass - @abstractmethod + def _request_package_action(self, request_type: RequestEnum, pkg: str) -> None: + ensured_upstream = self.gh_repo.get_root_repo() + upstream_namespace = ensured_upstream.namespace + issue_repo = self.gh_api.get_repo(upstream_namespace, self.gh_repo.repo_name) + + if request_type == RequestEnum.delete: + title = DELETE_PACKAGE_REQUEST_TITLE.format(package_name=pkg) + else: + title = CREATE_PACKAGE_REQUEST_TITLE.format(package_name=pkg) + + body = { + "request_type": request_type, + "user": self.gh_api.gh_user, + "package": pkg, + } + issue = issue_repo.create_issue(title, dumps(body)) + issue.add_to_labels(REQUEST_LABEL) + def request_package(self, package_name: str) -> None: - pass + self._request_package_action(RequestEnum.create, package_name) - @abstractmethod def request_package_delete(self, package: str) -> None: - pass + self._request_package_action(RequestEnum.delete, package) @staticmethod def _prepare_cloned_repo(where_to_clone: str, gh_repo: GithubRepo) -> None: diff --git a/alpa/repository/branch.py b/alpa/repository/branch.py index 0f1fb4c..06e965f 100644 --- a/alpa/repository/branch.py +++ b/alpa/repository/branch.py @@ -5,7 +5,7 @@ from pathlib import Path import re -from typing import Optional, Type +from typing import Optional from click import ClickException import click @@ -14,9 +14,6 @@ from alpa.constants import ( ALPA_FEAT_BRANCH_PREFIX, MAIN_BRANCH, - PackageRequest, - DeleteRequest, - REQUEST_LABEL, ) from alpa.gh import GithubAPI from alpa.messages import NO_WRITE_ACCESS_ERR @@ -145,24 +142,3 @@ def create_package(self, package: str) -> None: self.git_cmd(["switch", "-c", package]) self.git_cmd(["push", self.remote_name, package]) click.echo(f"Package {package} created") - - def _request_package_action( - self, action: Type[PackageRequest | DeleteRequest], pkg: str - ) -> None: - ensured_upstream = self.gh_repo.get_root_repo() - upstream_namespace = ensured_upstream.namespace - issue_repo = self.gh_api.get_repo(upstream_namespace, self.gh_repo.repo_name) - issue = issue_repo.create_issue( - action.TITLE.value.format(package_name=pkg), - action.BODY.value.format( - user=self.gh_api.gh_user, - package_name=pkg, - ), - ) - issue.add_to_labels(REQUEST_LABEL) - - def request_package(self, package_name: str) -> None: - self._request_package_action(PackageRequest, package_name) - - def request_package_delete(self, package: str) -> None: - self._request_package_action(DeleteRequest, package) diff --git a/pyproject.toml b/pyproject.toml index d489eab..5eecf7a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "pyalpa" -version = "0.9.1" +version = "0.10.0" description = "Integration tool with Alpa repository" authors = ["Jiri Kyjovsky "] maintainers = ["Jiří Kyjovský "] diff --git a/test/config.py b/test/config.py deleted file mode 100644 index d92400f..0000000 --- a/test/config.py +++ /dev/null @@ -1,2 +0,0 @@ -class FakeAlpaRepo: - pass diff --git a/test/conftest.py b/test/conftest.py deleted file mode 100644 index e69de29..0000000 diff --git a/test/constants.py b/test/constants.py index ff97b83..a763b16 100644 --- a/test/constants.py +++ b/test/constants.py @@ -5,8 +5,8 @@ anytia_backend: pypi targets_notify_on_fail: - - f36 - - centos + - fedora-36 + - centos-stream maintainers: - user: @@ -17,9 +17,9 @@ email: 123@random.r targets: - - f37 - - f36 - - centos + - fedora-37 + - fedora-36 + - centos-stream arch: - x86_64 @@ -38,9 +38,9 @@ email: 123@random.r targets: - - f37 - - f36 - - centos + - fedora-37 + - fedora-36 + - centos-stream """ @@ -72,7 +72,7 @@ allow_foreign_contributing: true targets: - - f32 + - fedora-32 arch: - aarch64 diff --git a/test/fake_alpa_repo.py b/test/fake_alpa_repo.py new file mode 100644 index 0000000..446c14d --- /dev/null +++ b/test/fake_alpa_repo.py @@ -0,0 +1,147 @@ +""" +Fake local git Alpa repository +""" + +import subprocess +import tempfile +from pathlib import Path +from unittest.mock import patch + +from alpa.repository.base import LocalRepo +from alpa.repository.branch import LocalRepoBranch +from test.constants import METADATA_CONFIG_MANDATORY_ONLY_KEYS + +ALPA_CONFIG_BASE = """ +--- +copr_owner: alpa-owner +copr_repo: alpa-repo +""" + +FAKE_SPEC_FILE = """ +Name: test-package +Version: 0.1.0 +Release: 1%{?dist} +Summary: Fake test package + +License: GPLv3 +URL: https://example.com/%{name} +Source0: %{url}/%{version}.tar.gz + + +%description +%{summary} + + +%changelog +* Fri May 12 2023 user@not-google.com +- initial release +""" + + +class FakeAlpaRepo: + # ABC stores all abstract methods to `__abstractmethods__`. By setting it to its + # default empty value, you can make it think like every abstract method was + # implemented + @patch("alpa.repository.base.LocalRepo.__abstractmethods__", frozenset()) + def setup_method(self, method): + self._bare_repo = tempfile.TemporaryDirectory() + self._local_repo = tempfile.TemporaryDirectory() + self._other_local_repo = tempfile.TemporaryDirectory() + + self.git_cmd(["--bare", "init"], self._bare_repo.name) + self._config_git_repo(self._bare_repo.name) + self.git_cmd(["branch", "-m", "main"], self._bare_repo.name) + + self.local_git_root = self._local_repo.name + self.git_cmd(["clone", self._bare_repo.name, self.local_git_root]) + self._config_git_repo(self.local_git_root) + self.git_cmd(["commit", "-m", "Initial commit", "--allow-empty"]) + self.git_cmd(["push"]) + + with open(f"{self.local_git_root}/.alpa.yaml", "w") as f: + f.write(ALPA_CONFIG_BASE) + + self.git_cmd(["add", ".alpa.yaml"]) + self.git_cmd(["commit", "-m", "Add base file for alpa repo config"]) + self.git_cmd(["push"]) + + self.other_local_git_root = self._other_local_repo.name + self.git_cmd(["clone", self._bare_repo.name, self.other_local_git_root]) + self._config_git_repo(self.other_local_git_root) + + self.local_repo = LocalRepo(Path(self.local_git_root)) + + def teardown_method(self, method): + self._bare_repo.cleanup() + self._local_repo.cleanup() + self._other_local_repo.cleanup() + + def _config_git_repo(self, repo): + self.git_cmd(["config", "--local", "user.email", "test-user@example.com"], repo) + self.git_cmd(["config", "--local", "user.name", "Suspicious Guy"], repo) + + def git_cmd(self, cmd, context=None): + if context is None and hasattr(self, "local_git_root"): + context = self.local_git_root + + if ( + hasattr(self, "other_local_git_root") + and context is not None + and context == self.other_local_git_root + ): + subprocess.run( + ["git", "fetch", "--all"], + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL, + cwd=context, + ) + subprocess.run( + ["git", "pull", "--all"], + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL, + cwd=context, + ) + + process = subprocess.run( + ["git"] + cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=context + ) + if process.returncode != 0: + return "" + + result = "" + if process.stderr: + result += process.stderr.decode() + + if process.stdout: + if result: + result += "\n" + + result += process.stdout.decode() + + return result + + +class FakeAlpaBranchRepo(FakeAlpaRepo): + def setup_method(self, method): + super().setup_method(method) + with open(f"{self.local_git_root}/.alpa.yaml", "a") as f: + f.write("repo_type: branch\n") + + self.packages = ["je", "hele", "pikachu"] + for package in self.packages: + self.setup_package(package) + + self.local_repo = LocalRepoBranch(Path(self.local_git_root)) + + def setup_package(self, package): + self.git_cmd(["switch", "main"]) + self.git_cmd(["switch", "-c", package]) + with open(f"{self.local_git_root}/metadata.yaml", "w") as f: + f.write(METADATA_CONFIG_MANDATORY_ONLY_KEYS) + + with open(f"{self.local_git_root}/{package}.spec", "w") as f: + f.write(FAKE_SPEC_FILE) + + self.git_cmd(["add", "."]) + self.git_cmd(["commit", "-m", f"Add package {package}"]) + self.git_cmd(["push", "origin", package]) diff --git a/test/integration/test_cli.py b/test/integration/test_cli.py deleted file mode 100644 index 9c74aaf..0000000 --- a/test/integration/test_cli.py +++ /dev/null @@ -1,36 +0,0 @@ -from test.config import FakeAlpaRepo - - -class TestCli(FakeAlpaRepo): - def test_show_history(self): - pass - - def test_create(self): - pass - - def test_delete(self): - pass - - def test_switch(self): - pass - - def test_request_package(self): - pass - - def test_commit(self): - pass - - def test_push(self): - pass - - def test_pull(self): - pass - - def test_clone(self): - pass - - def test_list(self): - pass - - def test_genspec(self): - pass diff --git a/test/integration/test_github.py b/test/integration/test_github.py deleted file mode 100644 index e69de29..0000000 diff --git a/test/integration/test_repository.py b/test/integration/test_repository.py index e69de29..0d111d5 100644 --- a/test/integration/test_repository.py +++ b/test/integration/test_repository.py @@ -0,0 +1,203 @@ +from pathlib import Path +from unittest.mock import patch, PropertyMock + +import pytest + +from alpa.constants import ALPA_FEAT_BRANCH_PREFIX +from alpa.repository.base import LocalRepo +from alpa.repository.branch import LocalRepoBranch +from test.fake_alpa_repo import FakeAlpaBranchRepo, FakeAlpaRepo + + +class Test: + def test_get_feat_branch_of_package(self): + assert LocalRepo.get_feat_branch_of_package("pkg") == "__feat_pkg" + + @pytest.mark.parametrize( + "remote_refs, result", + [ + pytest.param(["raz", "dva", "tri"], ["raz", "dva", "tri"]), + pytest.param(["dva", "__feat_dva", "tri"], ["dva", "tri"]), + pytest.param([], []), + pytest.param(["__feat_branch"], []), + ], + ) + def test_get_relevant_remote_refs(self, remote_refs, result): + assert LocalRepo._get_relevant_remote_refs(remote_refs) == result + + def test_parse_reponame_from_url(self): + assert ( + LocalRepo._parse_reponame_from_url("https://example.org/namespace/repo.git") + == "namespace/repo" + ) + assert ( + LocalRepo._parse_reponame_from_url("git@example.org:namespace/repo.git") + == "namespace/repo" + ) + + +class TestBaseRepo(FakeAlpaRepo): + def test_get_branch(self): + branch = "test-branch" + self.git_cmd(["switch", "-c", branch]) + assert self.local_repo.branch == branch + + @patch.object(LocalRepo, "package", new_callable=PropertyMock) + def test_get_feat_branch(self, mock_package): + branch = "test-branch" + mock_package.return_value = branch + + self.git_cmd(["switch", "-c", branch]) + assert self.local_repo.feat_branch == "__feat_test-branch" + + def test_get_remote_branches(self): + result = ["main"] + for branch in ["branch1", "branch2", "branch3"]: + result.append(branch) + self.git_cmd(["switch", "-c", branch]) + with open(f"{self.local_git_root}/file", "w") as f: + f.write("some change") + + self.git_cmd(["add", "file"]) + self.git_cmd(["commit", "-m", "commit some change"]) + self.git_cmd(["push", "origin", branch]) + assert sorted(self.local_repo.get_remote_branches("origin")) == sorted( + result + ) + + def test_remotes(self): + assert self.local_repo.remotes == {"origin"} + + self.git_cmd(["remote", "add", "something", "fake/remote.git"]) + assert self.local_repo.remotes == {"origin", "something"} + + def test_untracked_files(self): + with open(f"{self.local_git_root}/file1", "w") as f: + f.write("file1") + + with open(f"{self.local_git_root}/file2", "w") as f: + f.write("file2") + + assert self.local_repo.untracked_files == ["file1", "file2"] + + def test_is_dirty(self): + assert not self.local_repo.is_dirty() + + with open(f"{self.local_git_root}/file", "w") as f: + f.write("file") + + assert self.local_repo.is_dirty() + + self.git_cmd(["add", "file"]) + assert self.local_repo.is_dirty() + + self.git_cmd(["commit", "-m", "commit file"]) + assert not self.local_repo.is_dirty() + + def test_namespace(self): + self.git_cmd( + ["remote", "set-url", "origin", "https://example.org/namespace/repo.git"] + ) + assert self.local_repo.namespace == "namespace" + + self.git_cmd( + ["remote", "set-url", "origin", "git@example.org:namespace/repo.git"] + ) + assert self.local_repo.namespace == "namespace" + + def test_repo_name(self): + self.git_cmd( + ["remote", "set-url", "origin", "https://example.org/namespace/repo.git"] + ) + assert self.local_repo.repo_name == "repo" + + self.git_cmd( + ["remote", "set-url", "origin", "git@example.org:namespace/repo.git"] + ) + assert self.local_repo.repo_name == "repo" + + def test_branch_exists(self): + assert not self.local_repo.branch_exists("new-branch") + + self.git_cmd(["switch", "-c", "new-branch"]) + assert self.local_repo.branch_exists("new-branch") + + +class TestBranchRepo(FakeAlpaBranchRepo): + def test_package(self): + pkg = self.packages[0] + self.git_cmd(["switch", pkg]) + self.local_repo._ensure_feature_branch() + assert self.local_repo.package == pkg + + def test_get_packages(self): + assert set(self.packages) == set( + LocalRepoBranch(Path(self.local_git_root)).get_packages() + ) + + def test_switch_to_package(self): + pkg = self.packages[0] + pkg_to_switch = self.packages[1] + self.git_cmd(["switch", pkg]) + self.local_repo.switch_to_package(pkg_to_switch) + assert self.local_repo.package == self.local_repo.branch == pkg_to_switch + + def test_switch_to_non_existing_package(self): + pkg = self.packages[0] + self.git_cmd(["switch", pkg]) + self.local_repo.switch_to_package("non-existing-package") + assert self.local_repo.package == pkg + + def test_switch_to_feat_branch(self): + pkg = self.packages[0] + pkg_to_switch = self.packages[1] + self.git_cmd(["switch", pkg_to_switch]) + self.local_repo._ensure_feature_branch() + self.git_cmd(["push", "origin", self.local_repo.feat_branch]) + self.git_cmd(["switch", pkg]) + + self.local_repo.switch_to_package(pkg_to_switch) + assert ( + self.local_repo.package == pkg_to_switch + and self.local_repo.branch.startswith(ALPA_FEAT_BRANCH_PREFIX) + ) + + def test_switch_and_delete_feature_branch(self): + pkg = self.packages[0] + pkg_to_switch = self.packages[1] + self.git_cmd(["switch", pkg_to_switch]) + # no push to remote repo - no feature branch in it -> probably merged + self.local_repo._ensure_feature_branch() + self.git_cmd(["switch", pkg]) + + self.local_repo.switch_to_package(pkg_to_switch) + assert self.local_repo.package == self.local_repo.branch == pkg_to_switch + + def test_ensure_feature_branch(self): + self.local_repo._ensure_feature_branch() + assert self.local_repo.branch.startswith(ALPA_FEAT_BRANCH_PREFIX) + + def test_rebase_needed(self): + pkg = self.packages[0] + self.git_cmd(["switch", pkg]) + assert not self.local_repo._rebase_needed() + + with open(f"{self.local_git_root}/file.txt", "w") as f: + f.write("something") + + self.git_cmd(["add", "file.txt"]) + self.git_cmd(["commit", "-m", "adding new file"]) + self.git_cmd(["push", "origin", pkg]) + self.git_cmd(["pull", "origin", pkg]) + assert not self.local_repo._rebase_needed() + + self.git_cmd(["switch", "main"], self.other_local_git_root) + with open(f"{self.other_local_git_root}/.alpa.yaml", "a") as f: + f.write("adding new line\n") + + self.git_cmd(["add", ".alpa.yaml"], self.other_local_git_root) + self.git_cmd(["commit", "-m", "new change to main"], self.other_local_git_root) + self.git_cmd(["push", "origin", "main"], self.other_local_git_root) + + self.git_cmd(["switch", pkg]) + assert self.local_repo._rebase_needed() diff --git a/test/unit/test_alpa_repo_config.py b/test/unit/test_alpa_repo_config.py index d41ec1e..d3bf310 100644 --- a/test/unit/test_alpa_repo_config.py +++ b/test/unit/test_alpa_repo_config.py @@ -85,7 +85,7 @@ def test_load_alpa_config(self, fs: FakeFilesystem, alpa_config, path, result): pytest.param(ALPA_CONFIG_MANDATORY_KEYS, False), ], ) - @patch.object(AlpaRepoConfig, "_load_alpa_config") + @patch.object(AlpaRepoConfig, "get_config") def test_content_in_config_file( self, mock_load_alpa_config, alpa_config, everything ): @@ -99,7 +99,7 @@ def test_content_in_config_file( assert config.copr_repo == "alpa-repo" if everything: assert config.allow_foreign_contributing - assert config.targets == {"f32"} + assert config.targets == {"fedora-32"} assert config.arch == {"aarch64"} else: assert not config.allow_foreign_contributing diff --git a/test/unit/test_github.py b/test/unit/test_github.py deleted file mode 100644 index e69de29..0000000 diff --git a/test/unit/test_metadata_config.py b/test/unit/test_metadata_config.py index 6ff05e5..20b2afe 100644 --- a/test/unit/test_metadata_config.py +++ b/test/unit/test_metadata_config.py @@ -24,7 +24,7 @@ class TestMetadata: { "upstream_pkg_name": "some_package", "anytia_backend": "pypi", - "targets_notify_on_fail": ["f36", "centos"], + "targets_notify_on_fail": ["fedora-36", "centos-stream"], } ), pytest.param( @@ -40,7 +40,7 @@ def test_fill_autoupdate_dataclass(self, d): assert result.upstream_pkg_name == "some_package" assert result.anytia_backend == "pypi" if result.targets_notify_on_fail: - assert result.targets_notify_on_fail == {"f36", "centos"} + assert result.targets_notify_on_fail == {"fedora-36", "centos-stream"} @pytest.mark.parametrize( "d, missing", @@ -71,7 +71,7 @@ def test_fill_metadata_from_dict_runs(self, mock_get_config, raw_yaml): @pytest.mark.parametrize( "d, missing", [ - pytest.param({"targets": ["f37", "f38"]}, "maintainers"), + pytest.param({"targets": ["fedora-37", "fedora-38"]}, "maintainers"), pytest.param( { "maintainers": [ @@ -83,7 +83,7 @@ def test_fill_metadata_from_dict_runs(self, mock_get_config, raw_yaml): pytest.param( { "maintainers": [{}], - "targets": ["f33"], + "targets": ["fedora-33"], }, "maintainers.user", ), @@ -160,13 +160,16 @@ def __eq__(self, other): ) assert maintainers_cmp[1] == UserCmp(nick="random_guy", email="123@random.r") - assert metadata.targets == {"f36", "f37", "centos"} + assert metadata.targets == {"fedora-36", "fedora-37", "centos-stream"} if "autoupdate:" in metadata_config: assert metadata.autoupdate is not None assert metadata.autoupdate.upstream_pkg_name == "some_package" assert metadata.autoupdate.anytia_backend == "pypi" - assert metadata.autoupdate.targets_notify_on_fail == {"f36", "centos"} + assert metadata.autoupdate.targets_notify_on_fail == { + "fedora-36", + "centos-stream", + } else: assert metadata.autoupdate is None @@ -192,7 +195,7 @@ def test_content_in_config_file_with_alpa_repo_having_chroot_specified( repo_type=AlpaRepoType.branch, copr_owner="owner", copr_repo="repo", - targets={"f33"}, + targets={"fedora-33"}, arch={"aarch64"}, ) @@ -203,9 +206,14 @@ def test_content_in_config_file_with_alpa_repo_having_chroot_specified( metadata = MetadataConfig.get_config() if "targets:" in metadata_config: - assert metadata.targets == {"f33", "f36", "f37", "centos"} + assert metadata.targets == { + "fedora-33", + "fedora-36", + "fedora-37", + "centos-stream", + } else: - assert metadata.targets == {"f33"} + assert metadata.targets == {"fedora-33"} if "arch:" in metadata_config: assert metadata.arch == {"x86_64", "s390x", "aarch64"} @@ -216,10 +224,15 @@ def test_chroots(self): config = MetadataConfig( autoupdate=None, maintainers=[], - targets={"fedora-37", "centos"}, + targets={"fedora-37", "centos-stream"}, arch={"s390x", "aarch64"}, ) assert sorted(config.chroots) == sorted( - ["fedora-37-s390x", "centos-s390x", "fedora-37-aarch64", "centos-aarch64"] + [ + "fedora-37-s390x", + "centos-stream-s390x", + "fedora-37-aarch64", + "centos-stream-aarch64", + ] ) diff --git a/test/unit/test_packit.py b/test/unit/test_packit.py index 5e1acd8..03d4963 100644 --- a/test/unit/test_packit.py +++ b/test/unit/test_packit.py @@ -36,7 +36,13 @@ class TestPackitConfig: "job": "copr_build", "trigger": "pull_request", "targets": sorted( - list({"f36-x86_64", "f37-x86_64", "centos-x86_64"}) + list( + { + "fedora-36-x86_64", + "fedora-37-x86_64", + "centos-stream-x86_64", + } + ) ), "owner": "alpa-owner", "project": "alpa-repo-pull-requests", @@ -46,7 +52,13 @@ class TestPackitConfig: "trigger": "commit", "branch": "uwu", "targets": sorted( - list({"f36-x86_64", "f37-x86_64", "centos-x86_64"}) + list( + { + "fedora-36-x86_64", + "fedora-37-x86_64", + "centos-stream-x86_64", + } + ) ), "owner": "alpa-owner", "project": "alpa-repo", @@ -74,18 +86,18 @@ class TestPackitConfig: "targets": sorted( list( { - "f36-x86_64", - "f37-x86_64", - "centos-x86_64", - "f36-s390x", - "f37-s390x", - "centos-s390x", - "f36-aarch64", - "f37-aarch64", - "centos-aarch64", - "f32-x86_64", - "f32-s390x", - "f32-aarch64", + "fedora-36-x86_64", + "fedora-37-x86_64", + "centos-stream-x86_64", + "fedora-36-s390x", + "fedora-37-s390x", + "centos-stream-s390x", + "fedora-36-aarch64", + "fedora-37-aarch64", + "centos-stream-aarch64", + "fedora-32-x86_64", + "fedora-32-s390x", + "fedora-32-aarch64", } ) ), @@ -99,18 +111,18 @@ class TestPackitConfig: "targets": sorted( list( { - "f36-x86_64", - "f37-x86_64", - "centos-x86_64", - "f36-s390x", - "f37-s390x", - "centos-s390x", - "f36-aarch64", - "f37-aarch64", - "centos-aarch64", - "f32-x86_64", - "f32-s390x", - "f32-aarch64", + "fedora-36-x86_64", + "fedora-37-x86_64", + "centos-stream-x86_64", + "fedora-36-s390x", + "fedora-37-s390x", + "centos-stream-s390x", + "fedora-36-aarch64", + "fedora-37-aarch64", + "centos-stream-aarch64", + "fedora-32-x86_64", + "fedora-32-s390x", + "fedora-32-aarch64", } ) ), @@ -124,18 +136,18 @@ class TestPackitConfig: "targets": sorted( list( { - "f36-x86_64", - "f37-x86_64", - "centos-x86_64", - "f36-s390x", - "f37-s390x", - "centos-s390x", - "f36-aarch64", - "f37-aarch64", - "centos-aarch64", - "f32-x86_64", - "f32-s390x", - "f32-aarch64", + "fedora-36-x86_64", + "fedora-37-x86_64", + "centos-stream-x86_64", + "fedora-36-s390x", + "fedora-37-s390x", + "centos-stream-s390x", + "fedora-36-aarch64", + "fedora-37-aarch64", + "centos-stream-aarch64", + "fedora-32-x86_64", + "fedora-32-s390x", + "fedora-32-aarch64", } ) ), @@ -162,7 +174,7 @@ class TestPackitConfig: { "job": "copr_build", "trigger": "pull_request", - "targets": sorted(list({"f32-aarch64"})), + "targets": sorted(list({"fedora-32-aarch64"})), "owner": "alpa-owner", "project": "alpa-repo-pull-requests", }, @@ -170,7 +182,7 @@ class TestPackitConfig: "job": "copr_build", "trigger": "commit", "branch": "uwu", - "targets": sorted(list({"f32-aarch64"})), + "targets": sorted(list({"fedora-32-aarch64"})), "owner": "alpa-owner", "project": "alpa-repo", }, diff --git a/test/unit/test_repository.py b/test/unit/test_repository.py deleted file mode 100644 index e69de29..0000000