Пример #1
0
def test_get_builds(upstream_n_distgit, expected_results, br_list, number_of_builds):
    u, d = upstream_n_distgit
    from bodhi.client.bindings import BodhiClient

    c = get_test_config()
    pc = get_local_package_config(str(u))
    pc.downstream_project_url = str(d)
    pc.upstream_project_url = str(u)
    dg = DistGit(c, pc)
    pc = get_local_package_config(str(u))
    flexmock(BodhiClient).should_receive("latest_builds").and_return(
        BODHI_LATEST_BUILDS
    )
    status = Status(c, pc, u, dg)
    flexmock(
        PagureProject,
        get_git_urls=lambda: {"git": "foo.git"},
        fork_create=lambda: None,
        get_fork=lambda: PagureProject("", "", PagureService()),
        get_branches=br_list,
    )
    assert status
    table = status.get_builds(number_of_builds)
    assert table
    assert len(table.keys()) == number_of_builds
    assert table == expected_results
Пример #2
0
def test_status_updates(config_mock, package_config_mock, upstream_mock,
                        distgit_mock):
    flexmock(
        OurBodhiClient,
        query=lambda packages: {
            "updates": [
                {
                    "title": "python-requre-0.8.1-2.fc33",
                    "karma": 2,
                    "status": "stable",
                    "release": {
                        "branch": "f33"
                    },
                },
                {
                    "title": "python-requre-0.8.1-2.fc34",
                    "karma": 3,
                    "status": "stable",
                    "release": {
                        "branch": "f34"
                    },
                },
            ]
        },
    )

    status = Status(config_mock, package_config_mock, upstream_mock,
                    distgit_mock)
    table = status.get_updates()
    assert table == [
        ["python-requre-0.8.1-2.fc33", 2, "stable"],
        ["python-requre-0.8.1-2.fc34", 3, "stable"],
    ]
Пример #3
0
class TestStatus(PackitUnittestOgr):
    def setUp(self):
        super().setUp()
        self.status = Status(self.conf, self.pc, self.upstream, self.dg)

    def test_status(self):
        assert self.status

    def test_distgen_versions(self):
        table = self.status.get_dg_versions()
        assert table
        assert len(table) >= 3

    def test_builds(self):
        table = self.status.get_builds()
        assert table
        assert len(table) >= 2

    def test_updates(self):
        table = self.status.get_updates()
        assert table
        assert len(table) >= 3

    def test_up_releases(self):
        table = self.status.get_up_releases()
        assert len(table) >= 5

    def test_dowstream_pr(self):
        table = self.status.get_downstream_prs()
        assert len(table) == 0
Пример #4
0
    def status(self):
        status = Status(self.config, self.package_config, self.up, self.dg)

        ds_prs = status.get_downstream_prs()
        if ds_prs:
            logger.info("Downstream PRs:")
            logger.info(tabulate(ds_prs, headers=["ID", "Title", "URL"]))
        else:
            logger.info("Downstream PRs: No open PRs.")
        status.get_dg_versions()
        status.get_up_releases()
        builds = status.get_builds()
        if builds:
            logger.info("\nLatest builds:")
            for build in builds:
                koji_builds_str = "\n".join(f" - {b}" for b in builds[build])
                logger.info(f"{build}:\n{koji_builds_str}")
        else:
            logger.info("There are no builds.")

        updates = status.get_updates()
        if updates:
            logger.info("\nLatest bodhi updates:")
            logger.info(
                tabulate(updates, headers=["Update", "Karma", "status"]))
Пример #5
0
def test_get_releases(upstream_instance, distgit_instance, expected_releases):
    u, up = upstream_instance
    d, dg = distgit_instance
    c = get_test_config()
    pc = get_local_package_config(str(u))
    up.local_project.git_project = flexmock()

    flexmock(up.local_project.git_project).should_receive(
        "get_releases").and_return(expected_releases)
    status = Status(c, pc, up, dg)
    releases = status.get_up_releases()
    assert len(releases) == len(expected_releases)
    assert releases == expected_releases
Пример #6
0
def test_get_updates(upstream_n_distgit, expected_status, number_of_updates):
    u, d = upstream_n_distgit
    from bodhi.client.bindings import BodhiClient

    c = get_test_config()
    pc = get_local_package_config(str(u))
    pc.downstream_project_url = str(d)
    pc.upstream_project_url = str(u)
    dg = DistGit(c, pc)
    pc = get_local_package_config(str(u))
    flexmock(BodhiClient).should_receive("query").and_return(BODHI_UPDATES)
    status = Status(c, pc, u, dg)
    assert status
    table = status.get_updates(number_of_updates=number_of_updates)
    assert table
    assert len(table) == number_of_updates
    assert table == expected_status
Пример #7
0
    def status(self) -> None:
        status = Status(self.config, self.package_config, self.up, self.dg)
        if sys.version_info >= (3, 7, 0):
            res = asyncio.run(self.status_main(status))
        else:
            # backward compatibility for Python 3.6
            loop = asyncio.new_event_loop()
            asyncio.set_event_loop(loop)
            try:
                res = loop.run_until_complete(
                    asyncio.gather(
                        self.status_get_downstream_prs(status),
                        self.status_get_dg_versions(status),
                        self.status_get_up_releases(status),
                        self.status_get_builds(status),
                        self.status_get_updates(status),
                    )
                )
            finally:
                asyncio.set_event_loop(None)
                loop.close()

        (ds_prs, dg_versions, up_releases, builds, updates) = res

        if ds_prs:
            logger.info("\nDownstream PRs:")
            logger.info(tabulate(ds_prs, headers=["ID", "Title", "URL"]))
        else:
            logger.info("\nNo downstream PRs found.")

        if dg_versions:
            logger.info("\nDist-git versions:")
            for branch, dg_version in dg_versions.items():
                logger.info(f"{branch}: {dg_version}")
        else:
            logger.info("\nNo Dist-git versions found.")

        if up_releases:
            logger.info("\nUpstream releases:")
            upstream_releases_str = "\n".join(
                f"{release.tag_name}" for release in up_releases
            )
            logger.info(upstream_releases_str)
        else:
            logger.info("\nNo upstream releases found.")

        if updates:
            logger.info("\nLatest Bodhi updates:")
            logger.info(tabulate(updates, headers=["Update", "Karma", "status"]))
        else:
            logger.info("\nNo Bodhi updates found.")

        if builds:
            logger.info("\nLatest Koji builds:")
            for branch, branch_builds in builds.items():
                logger.info(f"{branch}: {branch_builds}")
        else:
            logger.info("No Koji builds found.")
Пример #8
0
def test_get_dg_versions(upstream_n_distgit, expected_versions):
    u, d = upstream_n_distgit

    c = get_test_config()
    pc = get_local_package_config(str(u))
    pc.downstream_project_url = str(d)
    pc.upstream_project_url = str(u)
    dg = DistGit(c, pc)

    flexmock(dg.local_project.git_project).should_receive(
        "get_branches").and_return(expected_versions.keys())
    flexmock(dg.specfile).should_receive("get_version").and_return("0.0.2")
    flexmock(dg).should_receive("checkout_branch").and_return(None)
    flexmock(dg).should_receive("create_branch").and_return(None)

    status = Status(c, pc, u, dg)
    dg_versions = status.get_dg_versions()
    assert dg_versions.keys() == expected_versions.keys()
    assert dg_versions == expected_versions
Пример #9
0
class TestStatus(PackitUnittestOgr):
    def setUp(self):
        DataMiner.key = f'github-{pkg_resources.get_distribution("PyGithub").version}'
        DataMiner.data_type = DataTypes.Dict
        super().setUp()
        self.status = Status(self.conf, self.pc, self.upstream, self.dg)

    def test_status(self):
        assert self.status

    def test_distgen_versions(self):
        table = self.status.get_dg_versions()
        assert table
        assert len(table) >= 3

    def test_builds(self):
        table = self.status.get_builds()
        assert table
        assert len(table) >= 2

    def test_updates(self):
        table = self.status.get_updates()
        assert table
        assert len(table) >= 3

        # Check if get_updates doesn't return more than one stable update per branch
        stable_branches = []
        for [update, _, status] in table:
            branch = update[-4:]
            if status == "stable":
                stable_branches.append(branch)
        assert len(set(stable_branches)) == len(stable_branches)

    @unittest.skip("The replaying does not work.")
    def test_up_releases(self):
        table = self.status.get_up_releases()
        assert len(table) >= 5

    def test_dowstream_pr(self):
        table = self.status.get_downstream_prs()
        assert len(table) >= 0
Пример #10
0
def test_downstream_pr(upstream_n_distgit, pr_list, number_prs):
    u, d = upstream_n_distgit

    c = get_test_config()
    pc = get_local_package_config(str(u))
    pc.downstream_project_url = str(d)
    pc.upstream_project_url = str(u)
    dg = DistGit(c, pc)
    pc = get_local_package_config(str(u))
    status = Status(c, pc, u, dg)
    flexmock(
        PagureProject,
        get_git_urls=lambda: {"git": "foo.git"},
        fork_create=lambda: None,
        get_fork=lambda: PagureProject("", "", PagureService()),
        get_pr_list=pr_list,
    )
    assert status
    table = status.get_downstream_prs(number_prs)
    assert table
    assert len(table) == number_prs
Пример #11
0
class TestStatus(PackitUnittestOgr):
    def setUp(self):
        super().setUp()
        self.status = Status(self.conf, self.pc, self.upstream, self.dg)

    def test_status(self):
        assert self.status

    def test_distgen_versions(self):
        table = self.status.get_dg_versions()
        assert table
        assert len(table) >= 3

    def test_builds(self):
        table = self.status.get_builds()
        assert table
        assert len(table) >= 2

    def test_updates(self):
        table = self.status.get_updates()
        assert table
        assert len(table) >= 3

        # Check if get_updates doesn't return more than one stable update per branch
        stable_branches = []
        for [update, _, status] in table:
            branch = update[-4:]
            if status == "stable":
                stable_branches.append(branch)
        assert len(set(stable_branches)) == len(stable_branches)

    def test_up_releases(self):
        table = self.status.get_up_releases()
        assert len(table) >= 5

    def test_dowstream_pr(self):
        table = self.status.get_downstream_prs()
        assert len(table) == 0
Пример #12
0
    def status(self):
        status = Status(self.config, self.package_config, self.up, self.dg)

        ds_prs = status.get_downstream_prs()
        if ds_prs:
            logger.info("Downstream PRs:")
            logger.info(tabulate(ds_prs, headers=["ID", "Title", "URL"]))
        else:
            logger.info("Downstream PRs: No open PRs.")

        dg_versions = status.get_dg_versions()
        if dg_versions:
            logger.info("Dist-git versions:")
            for branch, dg_version in dg_versions.items():
                logger.info(f"{branch}: {dg_version}")

        up_releases = status.get_up_releases()
        if up_releases:
            logger.info("\nGitHub upstream releases:")
            upstream_releases_str = "\n".join(f"{release.tag_name}"
                                              for release in up_releases)
            logger.info(upstream_releases_str)
        else:
            logger.info("\nGitHub upstream releases: No releases found.")

        builds = status.get_builds()
        if builds:
            logger.info("\nLatest builds:")
            for build in builds:
                koji_builds_str = "\n".join(f" - {b}" for b in builds[build])
                logger.info(f"{build}:\n{koji_builds_str}")
        else:
            logger.info("There are no builds.")

        updates = status.get_updates()
        if updates:
            logger.info("\nLatest bodhi updates:")
            logger.info(
                tabulate(updates, headers=["Update", "Karma", "status"]))
Пример #13
0
 def setUp(self):
     DataMiner.key = f'github-{pkg_resources.get_distribution("PyGithub").version}'
     DataMiner.data_type = DataTypes.Dict
     super().setUp()
     self.status = Status(self.conf, self.pc, self.upstream, self.dg)
Пример #14
0
 def setUp(self):
     super().setUp()
     self.status = Status(self.conf, self.pc, self.upstream, self.dg)
Пример #15
0
    def status(self):

        status = Status(self.config, self.package_config)

        status.get_downstream_prs()
        status.get_dg_versions()
        status.get_up_releases()
        status.get_builds()
        status.get_updates()
Пример #16
0
 def status(self):
     if not self._status:
         self._status = Status(self.config, self.pc, self.upstream, self.dg)
     return self._status