Beispiel #1
0
    def test_get_avilable_chroots(self, get_list_keys, expected_return):
        copr_client_mock = flexmock(mock_chroot_proxy=flexmock())
        copr_client_mock.mock_chroot_proxy.should_receive(
            "get_list.keys").and_return(get_list_keys)
        flexmock(packit.copr_helper.CoprClient).should_receive(
            "create_from_config_file").and_return(copr_client_mock)

        copr_helper = CoprHelper("_upstream_local_project")
        copr_helper.get_available_chroots.cache_clear()

        assert copr_helper.get_available_chroots() == expected_return
Beispiel #2
0
    def test_settings_url(self, owner, project, section, expected_suffix):
        copr_client_mock = flexmock(config={"copr_url": "https://fedoracloud.org"})

        flexmock(packit.copr_helper.CoprClient).should_receive(
            "create_from_config_file"
        ).and_return(copr_client_mock)
        copr_helper = CoprHelper("_upstream_local_project")

        assert (
            copr_helper.get_copr_settings_url(owner, project, section)
            == f"https://fedoracloud.org/coprs/{expected_suffix}"
        )
Beispiel #3
0
def test_create_copr_project(copr_client_mock):
    copr_helper = CoprHelper(flexmock(git_url="https://gitlab.com/"))
    flexmock(packit.copr_helper.CoprClient).should_receive(
        "create_from_config_file").and_return(copr_client_mock)

    copr_client_mock.project_proxy = flexmock()
    flexmock(copr_client_mock.project_proxy).should_receive("add").and_raise(
        CoprRequestException,
        "You already have a project named 'already-present'.")

    copr_helper.create_copr_project(
        chroots=["centos-stream-8-x86_64"],
        description="my fabulous test",
        instructions=None,
        owner="me",
        project="already-present",
    )
Beispiel #4
0
def get_valid_build_targets(*name: str, default: str = DEFAULT_VERSION) -> set:
    """
    Function generates set which contains build targets available also in copr chroots.

    :param name: name(s) of the system and version or target name. (passed to
                packit.config.aliases.get_build_targets() function)
            or target name (e.g. "fedora-30-x86_64" or "fedora-stable-x86_64")
    :param default: used if no positional argument was given
    :return: set of build targets available also in copr chroots
    """
    build_targets = get_build_targets(*name, default=default)
    logger.info(f"Build targets: {build_targets} ")
    copr_chroots = CoprHelper.get_available_chroots()
    logger.info(f"Copr chroots: {copr_chroots} ")
    logger.info(f"Result set: {set(build_targets) & set(copr_chroots)}")
    return set(build_targets) & set(copr_chroots)
Beispiel #5
0
 def copr_helper(self) -> CoprHelper:
     if self._copr_helper is None:
         self._copr_helper = CoprHelper(
             upstream_local_project=self.upstream_local_project)
     return self._copr_helper
Beispiel #6
0
def copr_helper(copr_url):
    """Create a mock CoprHelper, with a copr_client configured with 'copr_url'."""
    helper = CoprHelper(flexmock())
    helper._copr_client = flexmock(config={"copr_url": copr_url})
    return helper
Beispiel #7
0
 def get_copr_builds(self, number_of_builds: int = 5) -> List:
     return CoprHelper(
         upstream_local_project=self.up.local_project).get_copr_builds(
             number_of_builds=number_of_builds)
Beispiel #8
0
 def test__copr_web_build_url(self, copr_build):
     assert CoprHelper.copr_web_build_url(copr_build[0]) == copr_build[1]