| |
@@ -0,0 +1,626 @@
|
| |
+ import logging
|
| |
+ from unittest.mock import ANY, call, MagicMock, Mock, patch
|
| |
+
|
| |
+ import fedora_messaging.api
|
| |
+ import pytest
|
| |
+ import requests
|
| |
+
|
| |
+ import toddlers.plugins.pdc_update_critpath
|
| |
+
|
| |
+ if toddlers.plugins.pdc_update_critpath.dnf is None:
|
| |
+ pytest.skip(
|
| |
+ "We can't test this toddler without importing DNF", allow_module_level=True
|
| |
+ )
|
| |
+
|
| |
+
|
| |
+ class TestPDCUpdateCritpath:
|
| |
+
|
| |
+ toddler_cls = toddlers.plugins.pdc_update_critpath.PDCUpdateCritpath
|
| |
+
|
| |
+ def test_accepts_topic_invalid(self, toddler):
|
| |
+ assert toddler.accepts_topic("foo.bar") is False
|
| |
+
|
| |
+ @pytest.mark.parametrize(
|
| |
+ "topic",
|
| |
+ [
|
| |
+ "org.fedoraproject.*.toddlers.trigger.pdc_update_critpath",
|
| |
+ "org.fedoraproject.prod.toddlers.trigger.pdc_update_critpath",
|
| |
+ "org.fedoraproject.stg.toddlers.trigger.pdc_update_critpath",
|
| |
+ ],
|
| |
+ )
|
| |
+ def test_accepts_topic_valid(self, topic, toddler):
|
| |
+ assert toddler.accepts_topic(topic)
|
| |
+
|
| |
+ @patch("toddlers.plugins.pdc_update_critpath.pdc_client_for_config")
|
| |
+ def test_process_no_primary_arch(self, pdc, toddler):
|
| |
+ client = Mock()
|
| |
+ pdc.return_value = client
|
| |
+
|
| |
+ msg = fedora_messaging.api.Message()
|
| |
+ msg.id = 123
|
| |
+ msg.topic = "org.fedoraproject.prod.toddlers.trigger.pdc_update_critpath"
|
| |
+ msg.body = {}
|
| |
+
|
| |
+ with pytest.raises(KeyError, match=r"primary_arches"):
|
| |
+ toddler.process({"config": "foobar"}, msg)
|
| |
+
|
| |
+ @patch("toddlers.plugins.pdc_update_critpath.pdc_client_for_config")
|
| |
+ def test_process_no_alternate_arches(self, pdc, toddler):
|
| |
+ client = Mock()
|
| |
+ pdc.return_value = client
|
| |
+
|
| |
+ msg = fedora_messaging.api.Message()
|
| |
+ msg.id = 123
|
| |
+ msg.topic = "org.fedoraproject.prod.toddlers.trigger.pdc_update_critpath"
|
| |
+ msg.body = {}
|
| |
+
|
| |
+ with pytest.raises(KeyError, match=r"alternate_arches"):
|
| |
+ toddler.process({"primary_arches": ["armhfp", "aarch64", "x86_64"]}, msg)
|
| |
+
|
| |
+ @patch("toddlers.plugins.pdc_update_critpath.pdc_client_for_config")
|
| |
+ def test_process_no_releases(self, pdc, toddler):
|
| |
+ client = Mock()
|
| |
+ pdc.return_value = client
|
| |
+
|
| |
+ msg = fedora_messaging.api.Message()
|
| |
+ msg.id = 123
|
| |
+ msg.topic = "org.fedoraproject.prod.toddlers.trigger.pdc_update_critpath"
|
| |
+ msg.body = {}
|
| |
+
|
| |
+ config = {
|
| |
+ "primary_arches": ["armhfp", "aarch64", "x86_64"],
|
| |
+ "alternate_arches": ["ppc64le", "s390x"],
|
| |
+ }
|
| |
+
|
| |
+ with pytest.raises(KeyError, match=r"releases"):
|
| |
+ toddler.process(config, msg)
|
| |
+
|
| |
+ @patch("dnf.const.VERSION")
|
| |
+ @patch("toddlers.plugins.pdc_update_critpath.pdc_client_for_config")
|
| |
+ def test_process_old_dnf(self, pdc, dnf_vers, toddler):
|
| |
+ client = Mock()
|
| |
+ pdc.return_value = client
|
| |
+
|
| |
+ msg = fedora_messaging.api.Message()
|
| |
+ msg.id = 123
|
| |
+ msg.topic = "org.fedoraproject.prod.toddlers.trigger.pdc_update_critpath"
|
| |
+ msg.body = {}
|
| |
+
|
| |
+ config = {
|
| |
+ "primary_arches": ["armhfp", "aarch64", "x86_64"],
|
| |
+ "alternate_arches": ["ppc64le", "s390x"],
|
| |
+ "releases": ["rawhide", "33", "32"],
|
| |
+ }
|
| |
+
|
| |
+ with pytest.raises(
|
| |
+ Exception, match=r"This script requires the DNF version 2.0 API."
|
| |
+ ):
|
| |
+ toddler.process(config, msg)
|
| |
+
|
| |
+ @patch(
|
| |
+ "toddlers.plugins.pdc_update_critpath.PDCUpdateCritpath.get_critpath_packages"
|
| |
+ )
|
| |
+ @patch("toddlers.plugins.pdc_update_critpath.pdc_client_for_config")
|
| |
+ def test_process_no_critpath_pkgs_nopdc(self, pdc, get_c_pkgs, toddler, caplog):
|
| |
+ caplog.set_level(logging.INFO)
|
| |
+
|
| |
+ client = Mock()
|
| |
+ pdc.return_value = client
|
| |
+ get_c_pkgs.return_value = []
|
| |
+
|
| |
+ msg = fedora_messaging.api.Message()
|
| |
+ msg.id = 123
|
| |
+ msg.topic = "org.fedoraproject.prod.toddlers.trigger.pdc_update_critpath"
|
| |
+ msg.body = {}
|
| |
+
|
| |
+ config = {
|
| |
+ "primary_arches": ["armhfp", "aarch64", "x86_64"],
|
| |
+ "alternate_arches": ["ppc64le", "s390x"],
|
| |
+ "releases": ["rawhide", "33", "32"],
|
| |
+ }
|
| |
+ toddler.process(config, msg, nopdc=True)
|
| |
+ get_c_pkgs.assert_has_calls(
|
| |
+ calls=[
|
| |
+ call(
|
| |
+ {
|
| |
+ "primary_arches": ["armhfp", "aarch64", "x86_64"],
|
| |
+ "alternate_arches": ["ppc64le", "s390x"],
|
| |
+ "releases": ["rawhide", "33", "32"],
|
| |
+ },
|
| |
+ "rawhide",
|
| |
+ check_arches=["armhfp", "aarch64", "x86_64"],
|
| |
+ alternate_check_arches=["ppc64le", "s390x"],
|
| |
+ ),
|
| |
+ call(
|
| |
+ {
|
| |
+ "primary_arches": ["armhfp", "aarch64", "x86_64"],
|
| |
+ "alternate_arches": ["ppc64le", "s390x"],
|
| |
+ "releases": ["rawhide", "33", "32"],
|
| |
+ },
|
| |
+ "33",
|
| |
+ check_arches=["armhfp", "aarch64", "x86_64"],
|
| |
+ alternate_check_arches=["ppc64le", "s390x"],
|
| |
+ ),
|
| |
+ call(
|
| |
+ {
|
| |
+ "primary_arches": ["armhfp", "aarch64", "x86_64"],
|
| |
+ "alternate_arches": ["ppc64le", "s390x"],
|
| |
+ "releases": ["rawhide", "33", "32"],
|
| |
+ },
|
| |
+ "32",
|
| |
+ check_arches=["armhfp", "aarch64", "x86_64"],
|
| |
+ alternate_check_arches=["ppc64le", "s390x"],
|
| |
+ ),
|
| |
+ ]
|
| |
+ )
|
| |
+
|
| |
+ assert caplog.records[-3].message == "0 packages found in rawhide"
|
| |
+ assert caplog.records[-2].message == "0 packages found in 33"
|
| |
+ assert caplog.records[-1].message == "0 packages found in 32"
|
| |
+
|
| |
+ @patch("toddlers.plugins.pdc_update_critpath.update_critpath")
|
| |
+ @patch("toddlers.plugins.pdc_update_critpath.list_critpath")
|
| |
+ @patch("toddlers.plugins.pdc_update_critpath.prepend_pdc_branch_ids")
|
| |
+ @patch(
|
| |
+ "toddlers.plugins.pdc_update_critpath.PDCUpdateCritpath.get_critpath_packages"
|
| |
+ )
|
| |
+ @patch("toddlers.plugins.pdc_update_critpath.pdc_client_for_config")
|
| |
+ def test_process(
|
| |
+ self,
|
| |
+ pdc,
|
| |
+ get_c_pkgs,
|
| |
+ prepend_pdc_branch_ids,
|
| |
+ list_critpath,
|
| |
+ update_critpath,
|
| |
+ toddler,
|
| |
+ caplog,
|
| |
+ ):
|
| |
+ caplog.set_level(logging.INFO)
|
| |
+
|
| |
+ client = MagicMock()
|
| |
+ pdc.return_value = client
|
| |
+ prepend_pdc_branch_ids.side_effect = [
|
| |
+ requests.RequestException("ahah"),
|
| |
+ set(["543:dnf", "321:kernel"]),
|
| |
+ ]
|
| |
+ list_critpath.side_effect = [
|
| |
+ requests.RequestException("ahah"),
|
| |
+ set(["543:dnf", "321:kernel", "876:python3"]),
|
| |
+ ]
|
| |
+ update_critpath.side_effect = [Exception("nope nope nope")]
|
| |
+ get_c_pkgs.return_value = []
|
| |
+
|
| |
+ msg = fedora_messaging.api.Message()
|
| |
+ msg.id = 123
|
| |
+ msg.topic = "org.fedoraproject.prod.toddlers.trigger.pdc_update_critpath"
|
| |
+ msg.body = {}
|
| |
+
|
| |
+ config = {
|
| |
+ "primary_arches": ["armhfp", "aarch64", "x86_64"],
|
| |
+ "alternate_arches": ["ppc64le", "s390x"],
|
| |
+ "releases": ["rawhide"],
|
| |
+ }
|
| |
+ with pytest.raises(Exception, match=r"nope nope nope"):
|
| |
+ toddler.process(config, msg)
|
| |
+
|
| |
+ get_c_pkgs.assert_has_calls(
|
| |
+ calls=[
|
| |
+ call(
|
| |
+ {
|
| |
+ "primary_arches": ["armhfp", "aarch64", "x86_64"],
|
| |
+ "alternate_arches": ["ppc64le", "s390x"],
|
| |
+ "releases": ["rawhide"],
|
| |
+ },
|
| |
+ "rawhide",
|
| |
+ check_arches=["armhfp", "aarch64", "x86_64"],
|
| |
+ alternate_check_arches=["ppc64le", "s390x"],
|
| |
+ ),
|
| |
+ ]
|
| |
+ )
|
| |
+ update_critpath.assert_has_calls(
|
| |
+ calls=[
|
| |
+ call(
|
| |
+ client,
|
| |
+ {"543:dnf", "321:kernel", "876:python3"},
|
| |
+ {"543:dnf", "321:kernel"},
|
| |
+ "rawhide",
|
| |
+ )
|
| |
+ ]
|
| |
+ )
|
| |
+
|
| |
+ assert "0 packages found in rawhide" in caplog.text
|
| |
+
|
| |
+ def test_get_critpath_packages_invalid_config_dl_baseurl(self, toddler, caplog):
|
| |
+ caplog.set_level(logging.INFO)
|
| |
+
|
| |
+ config = {
|
| |
+ "primary_arches": ["armhfp", "aarch64", "x86_64"],
|
| |
+ "alternate_arches": ["ppc64le", "s390x"],
|
| |
+ "releases": ["rawhide"],
|
| |
+ }
|
| |
+ with pytest.raises(Exception, match=r"fedora_dl_baseurl"):
|
| |
+ toddler.get_critpath_packages(
|
| |
+ config, "invalid", config["primary_arches"], config["alternate_arches"]
|
| |
+ )
|
| |
+
|
| |
+ def test_get_critpath_packages_invalid_config_fakearch(self, toddler, caplog):
|
| |
+ caplog.set_level(logging.INFO)
|
| |
+
|
| |
+ config = {
|
| |
+ "primary_arches": ["armhfp", "aarch64", "x86_64"],
|
| |
+ "alternate_arches": ["ppc64le", "s390x"],
|
| |
+ "releases": ["rawhide"],
|
| |
+ "fedora_dl_baseurl": "http://dl.fedoraproject.org/pub/fedora/linux/",
|
| |
+ }
|
| |
+ with pytest.raises(Exception, match=r"fakearch"):
|
| |
+ toddler.get_critpath_packages(
|
| |
+ config, "invalid", config["primary_arches"], config["alternate_arches"]
|
| |
+ )
|
| |
+
|
| |
+ def test_get_critpath_packages_invalid_config_releasepath(self, toddler, caplog):
|
| |
+ caplog.set_level(logging.INFO)
|
| |
+
|
| |
+ config = {
|
| |
+ "primary_arches": ["armhfp", "aarch64", "x86_64"],
|
| |
+ "alternate_arches": ["ppc64le", "s390x"],
|
| |
+ "releases": ["rawhide"],
|
| |
+ "fedora_dl_baseurl": "http://dl.fedoraproject.org/pub/fedora/linux/",
|
| |
+ "fakearch": {
|
| |
+ "i386": "i686",
|
| |
+ "x86_64": "x86_64",
|
| |
+ "ppc64": "ppc64",
|
| |
+ "ppc": "ppc64",
|
| |
+ "armhfp": "armv7hl",
|
| |
+ "aarch64": "aarch64",
|
| |
+ "ppc64le": "ppc64le",
|
| |
+ "s390x": "s390x",
|
| |
+ },
|
| |
+ }
|
| |
+ with pytest.raises(Exception, match=r"releasepath"):
|
| |
+ toddler.get_critpath_packages(
|
| |
+ config, "invalid", config["primary_arches"], config["alternate_arches"]
|
| |
+ )
|
| |
+
|
| |
+ def test_get_critpath_packages_invalid_arch(self, toddler, caplog):
|
| |
+ caplog.set_level(logging.INFO)
|
| |
+
|
| |
+ config = {
|
| |
+ "primary_arches": ["armhfp", "aarch64", "x86_64"],
|
| |
+ "alternate_arches": ["ppc64le", "s390x"],
|
| |
+ "releases": ["rawhide"],
|
| |
+ "fedora_dl_baseurl": "http://dl.fedoraproject.org/pub/fedora/linux/",
|
| |
+ "fakearch": {
|
| |
+ "i386": "i686",
|
| |
+ "x86_64": "x86_64",
|
| |
+ "ppc64": "ppc64",
|
| |
+ "ppc": "ppc64",
|
| |
+ "armhfp": "armv7hl",
|
| |
+ "aarch64": "aarch64",
|
| |
+ "ppc64le": "ppc64le",
|
| |
+ "s390x": "s390x",
|
| |
+ },
|
| |
+ "releasepath": {
|
| |
+ "rawhide": "development/rawhide/Everything/$basearch/os/",
|
| |
+ "33": "releases/33/Everything/$basearch/os/",
|
| |
+ },
|
| |
+ }
|
| |
+ with pytest.raises(Exception, match=r"invalid"):
|
| |
+ toddler.get_critpath_packages(
|
| |
+ config, "invalid", config["primary_arches"], config["alternate_arches"]
|
| |
+ )
|
| |
+
|
| |
+ def test_get_critpath_packages_invalid_config_critpath_groups(
|
| |
+ self, toddler, caplog
|
| |
+ ):
|
| |
+ caplog.set_level(logging.INFO)
|
| |
+
|
| |
+ config = {
|
| |
+ "primary_arches": ["armhfp", "aarch64", "x86_64"],
|
| |
+ "alternate_arches": ["ppc64le", "s390x"],
|
| |
+ "releases": ["rawhide"],
|
| |
+ "fedora_dl_baseurl": "http://dl.fedoraproject.org/pub/fedora/linux/",
|
| |
+ "fakearch": {
|
| |
+ "i386": "i686",
|
| |
+ "x86_64": "x86_64",
|
| |
+ "ppc64": "ppc64",
|
| |
+ "ppc": "ppc64",
|
| |
+ "armhfp": "armv7hl",
|
| |
+ "aarch64": "aarch64",
|
| |
+ "ppc64le": "ppc64le",
|
| |
+ "s390x": "s390x",
|
| |
+ },
|
| |
+ "releasepath": {
|
| |
+ "rawhide": "development/rawhide/Everything/$basearch/os/",
|
| |
+ "33": "releases/33/Everything/$basearch/os/",
|
| |
+ },
|
| |
+ }
|
| |
+ with pytest.raises(Exception, match=r"critpath_groups"):
|
| |
+ toddler.get_critpath_packages(
|
| |
+ config, "rawhide", config["primary_arches"], config["alternate_arches"]
|
| |
+ )
|
| |
+
|
| |
+ @patch("toddlers.plugins.pdc_update_critpath.expand_dnf_critpath")
|
| |
+ def test_get_critpath_packages(self, expand_dnf_critpath, toddler, caplog):
|
| |
+ caplog.set_level(logging.INFO)
|
| |
+ p1 = MagicMock()
|
| |
+ p1.name = "dnf"
|
| |
+ p2 = MagicMock()
|
| |
+ p2.name = "kernel"
|
| |
+ expand_dnf_critpath.return_value = [p1, p2]
|
| |
+
|
| |
+ config = {
|
| |
+ "primary_arches": ["armhfp", "aarch64", "x86_64"],
|
| |
+ "alternate_arches": ["ppc64le", "s390x"],
|
| |
+ "releases": ["rawhide"],
|
| |
+ "fedora_dl_baseurl": "http://dl.fedoraproject.org/pub/fedora/linux/",
|
| |
+ "fedora_dl_alternateurl": "http://dl.fedoraproject.org/pub/fedora-secondary/",
|
| |
+ "fakearch": {
|
| |
+ "i386": "i686",
|
| |
+ "x86_64": "x86_64",
|
| |
+ "ppc64": "ppc64",
|
| |
+ "ppc": "ppc64",
|
| |
+ "armhfp": "armv7hl",
|
| |
+ "aarch64": "aarch64",
|
| |
+ "ppc64le": "ppc64le",
|
| |
+ "s390x": "s390x",
|
| |
+ },
|
| |
+ "releasepath": {
|
| |
+ "rawhide": "development/rawhide/Everything/$basearch/os/",
|
| |
+ "33": "releases/33/Everything/$basearch/os/",
|
| |
+ },
|
| |
+ "critpath_groups": [
|
| |
+ "@core",
|
| |
+ "@critical-path-apps",
|
| |
+ "@critical-path-base",
|
| |
+ "@critical-path-gnome",
|
| |
+ "@critical-path-kde",
|
| |
+ "@critical-path-lxde",
|
| |
+ "@critical-path-xfce",
|
| |
+ ],
|
| |
+ }
|
| |
+ toddler.get_critpath_packages(
|
| |
+ config, "rawhide", config["primary_arches"], config["alternate_arches"]
|
| |
+ )
|
| |
+
|
| |
+ expand_dnf_critpath.assert_has_calls(
|
| |
+ calls=[
|
| |
+ call(
|
| |
+ "http://dl.fedoraproject.org/pub/fedora/linux/",
|
| |
+ "rawhide",
|
| |
+ "armhfp",
|
| |
+ {
|
| |
+ "primary_arches": ["armhfp", "aarch64", "x86_64"],
|
| |
+ "alternate_arches": ["ppc64le", "s390x"],
|
| |
+ "releases": ["rawhide"],
|
| |
+ "fedora_dl_baseurl": "http://dl.fedoraproject.org/pub/fedora/linux/",
|
| |
+ "fedora_dl_alternateurl": "http://dl.fedoraproject.org/"
|
| |
+ "pub/fedora-secondary/",
|
| |
+ "fakearch": {
|
| |
+ "i386": "i686",
|
| |
+ "x86_64": "x86_64",
|
| |
+ "ppc64": "ppc64",
|
| |
+ "ppc": "ppc64",
|
| |
+ "armhfp": "armv7hl",
|
| |
+ "aarch64": "aarch64",
|
| |
+ "ppc64le": "ppc64le",
|
| |
+ "s390x": "s390x",
|
| |
+ },
|
| |
+ "releasepath": {
|
| |
+ "rawhide": "development/rawhide/Everything/$basearch/os/",
|
| |
+ "33": "releases/33/Everything/$basearch/os/",
|
| |
+ },
|
| |
+ "critpath_groups": [
|
| |
+ "@core",
|
| |
+ "@critical-path-apps",
|
| |
+ "@critical-path-base",
|
| |
+ "@critical-path-gnome",
|
| |
+ "@critical-path-kde",
|
| |
+ "@critical-path-lxde",
|
| |
+ "@critical-path-xfce",
|
| |
+ ],
|
| |
+ },
|
| |
+ ),
|
| |
+ call(
|
| |
+ "http://dl.fedoraproject.org/pub/fedora/linux/",
|
| |
+ "rawhide",
|
| |
+ "aarch64",
|
| |
+ {
|
| |
+ "primary_arches": ["armhfp", "aarch64", "x86_64"],
|
| |
+ "alternate_arches": ["ppc64le", "s390x"],
|
| |
+ "releases": ["rawhide"],
|
| |
+ "fedora_dl_baseurl": "http://dl.fedoraproject.org/pub/fedora/linux/",
|
| |
+ "fedora_dl_alternateurl": "http://dl.fedoraproject.org/"
|
| |
+ "pub/fedora-secondary/",
|
| |
+ "fakearch": {
|
| |
+ "i386": "i686",
|
| |
+ "x86_64": "x86_64",
|
| |
+ "ppc64": "ppc64",
|
| |
+ "ppc": "ppc64",
|
| |
+ "armhfp": "armv7hl",
|
| |
+ "aarch64": "aarch64",
|
| |
+ "ppc64le": "ppc64le",
|
| |
+ "s390x": "s390x",
|
| |
+ },
|
| |
+ "releasepath": {
|
| |
+ "rawhide": "development/rawhide/Everything/$basearch/os/",
|
| |
+ "33": "releases/33/Everything/$basearch/os/",
|
| |
+ },
|
| |
+ "critpath_groups": [
|
| |
+ "@core",
|
| |
+ "@critical-path-apps",
|
| |
+ "@critical-path-base",
|
| |
+ "@critical-path-gnome",
|
| |
+ "@critical-path-kde",
|
| |
+ "@critical-path-lxde",
|
| |
+ "@critical-path-xfce",
|
| |
+ ],
|
| |
+ },
|
| |
+ ),
|
| |
+ call(
|
| |
+ "http://dl.fedoraproject.org/pub/fedora/linux/",
|
| |
+ "rawhide",
|
| |
+ "x86_64",
|
| |
+ {
|
| |
+ "primary_arches": ["armhfp", "aarch64", "x86_64"],
|
| |
+ "alternate_arches": ["ppc64le", "s390x"],
|
| |
+ "releases": ["rawhide"],
|
| |
+ "fedora_dl_baseurl": "http://dl.fedoraproject.org/pub/fedora/linux/",
|
| |
+ "fedora_dl_alternateurl": "http://dl.fedoraproject.org/"
|
| |
+ "pub/fedora-secondary/",
|
| |
+ "fakearch": {
|
| |
+ "i386": "i686",
|
| |
+ "x86_64": "x86_64",
|
| |
+ "ppc64": "ppc64",
|
| |
+ "ppc": "ppc64",
|
| |
+ "armhfp": "armv7hl",
|
| |
+ "aarch64": "aarch64",
|
| |
+ "ppc64le": "ppc64le",
|
| |
+ "s390x": "s390x",
|
| |
+ },
|
| |
+ "releasepath": {
|
| |
+ "rawhide": "development/rawhide/Everything/$basearch/os/",
|
| |
+ "33": "releases/33/Everything/$basearch/os/",
|
| |
+ },
|
| |
+ "critpath_groups": [
|
| |
+ "@core",
|
| |
+ "@critical-path-apps",
|
| |
+ "@critical-path-base",
|
| |
+ "@critical-path-gnome",
|
| |
+ "@critical-path-kde",
|
| |
+ "@critical-path-lxde",
|
| |
+ "@critical-path-xfce",
|
| |
+ ],
|
| |
+ },
|
| |
+ ),
|
| |
+ call(
|
| |
+ "http://dl.fedoraproject.org/pub/fedora-secondary/",
|
| |
+ "rawhide",
|
| |
+ "ppc64le",
|
| |
+ {
|
| |
+ "primary_arches": ["armhfp", "aarch64", "x86_64"],
|
| |
+ "alternate_arches": ["ppc64le", "s390x"],
|
| |
+ "releases": ["rawhide"],
|
| |
+ "fedora_dl_baseurl": "http://dl.fedoraproject.org/pub/fedora/linux/",
|
| |
+ "fedora_dl_alternateurl": "http://dl.fedoraproject.org/"
|
| |
+ "pub/fedora-secondary/",
|
| |
+ "fakearch": {
|
| |
+ "i386": "i686",
|
| |
+ "x86_64": "x86_64",
|
| |
+ "ppc64": "ppc64",
|
| |
+ "ppc": "ppc64",
|
| |
+ "armhfp": "armv7hl",
|
| |
+ "aarch64": "aarch64",
|
| |
+ "ppc64le": "ppc64le",
|
| |
+ "s390x": "s390x",
|
| |
+ },
|
| |
+ "releasepath": {
|
| |
+ "rawhide": "development/rawhide/Everything/$basearch/os/",
|
| |
+ "33": "releases/33/Everything/$basearch/os/",
|
| |
+ },
|
| |
+ "critpath_groups": [
|
| |
+ "@core",
|
| |
+ "@critical-path-apps",
|
| |
+ "@critical-path-base",
|
| |
+ "@critical-path-gnome",
|
| |
+ "@critical-path-kde",
|
| |
+ "@critical-path-lxde",
|
| |
+ "@critical-path-xfce",
|
| |
+ ],
|
| |
+ },
|
| |
+ ),
|
| |
+ call(
|
| |
+ "http://dl.fedoraproject.org/pub/fedora-secondary/",
|
| |
+ "rawhide",
|
| |
+ "s390x",
|
| |
+ {
|
| |
+ "primary_arches": ["armhfp", "aarch64", "x86_64"],
|
| |
+ "alternate_arches": ["ppc64le", "s390x"],
|
| |
+ "releases": ["rawhide"],
|
| |
+ "fedora_dl_baseurl": "http://dl.fedoraproject.org/pub/fedora/linux/",
|
| |
+ "fedora_dl_alternateurl": "http://dl.fedoraproject.org/"
|
| |
+ "pub/fedora-secondary/",
|
| |
+ "fakearch": {
|
| |
+ "i386": "i686",
|
| |
+ "x86_64": "x86_64",
|
| |
+ "ppc64": "ppc64",
|
| |
+ "ppc": "ppc64",
|
| |
+ "armhfp": "armv7hl",
|
| |
+ "aarch64": "aarch64",
|
| |
+ "ppc64le": "ppc64le",
|
| |
+ "s390x": "s390x",
|
| |
+ },
|
| |
+ "releasepath": {
|
| |
+ "rawhide": "development/rawhide/Everything/$basearch/os/",
|
| |
+ "33": "releases/33/Everything/$basearch/os/",
|
| |
+ },
|
| |
+ "critpath_groups": [
|
| |
+ "@core",
|
| |
+ "@critical-path-apps",
|
| |
+ "@critical-path-base",
|
| |
+ "@critical-path-gnome",
|
| |
+ "@critical-path-kde",
|
| |
+ "@critical-path-lxde",
|
| |
+ "@critical-path-xfce",
|
| |
+ ],
|
| |
+ },
|
| |
+ ),
|
| |
+ ]
|
| |
+ )
|
| |
+
|
| |
+
|
| |
+ class TestPDCUpdateCritpathCLI:
|
| |
+
|
| |
+ toddler_cls = toddlers.plugins.pdc_update_critpath.PDCUpdateCritpath
|
| |
+
|
| |
+ def test_main_no_args(self, capsys):
|
| |
+ with pytest.raises(SystemExit):
|
| |
+ toddlers.plugins.pdc_update_critpath.main([])
|
| |
+
|
| |
+ out, err = capsys.readouterr()
|
| |
+ assert out == ""
|
| |
+ # Expecting something along these lines, but don't make the test too tight:
|
| |
+ #
|
| |
+ # usage: pytest [-h] [--dry-run] [-q | --debug] conf [username]
|
| |
+ # pytest: error: the following arguments are required: conf
|
| |
+ assert err.startswith("usage:")
|
| |
+ assert "error: the following arguments are required:" in err
|
| |
+
|
| |
+ @patch("toddlers.plugins.pdc_update_critpath.PDCUpdateCritpath.process")
|
| |
+ @patch("toddlers.plugins.pdc_import_compose.pdc_client_for_config")
|
| |
+ @patch("toml.load", new=Mock(return_value={}))
|
| |
+ def test_main_debug(self, pdc, process, capsys):
|
| |
+ client = Mock()
|
| |
+ pdc.return_value = client
|
| |
+
|
| |
+ msg = fedora_messaging.api.Message()
|
| |
+ msg.id = ANY
|
| |
+ msg.topic = "org.fedoraproject.prod.toddlers.trigger.pdc_update_critpath"
|
| |
+ msg.body = {}
|
| |
+
|
| |
+ toddlers.plugins.pdc_update_critpath.main(["test.cfg", "--debug"])
|
| |
+ process.assert_called_once_with(
|
| |
+ config={}, message=None, releases=None, nopdc=False
|
| |
+ )
|
| |
+ out, err = capsys.readouterr()
|
| |
+ assert out == ""
|
| |
+ assert err == ""
|
| |
+
|
| |
+ @patch("toddlers.plugins.pdc_update_critpath.PDCUpdateCritpath.process")
|
| |
+ @patch("toddlers.plugins.pdc_import_compose.pdc_client_for_config")
|
| |
+ @patch("toml.load", new=Mock(return_value={}))
|
| |
+ def test_main(self, pdc, process, capsys):
|
| |
+ client = Mock()
|
| |
+ pdc.return_value = client
|
| |
+
|
| |
+ msg = fedora_messaging.api.Message()
|
| |
+ msg.id = ANY
|
| |
+ msg.topic = "org.fedoraproject.prod.toddlers.trigger.pdc_update_critpath"
|
| |
+ msg.body = {}
|
| |
+
|
| |
+ toddlers.plugins.pdc_update_critpath.main(["test.cfg"])
|
| |
+ process.assert_called_once_with(
|
| |
+ config={}, message=None, releases=None, nopdc=False
|
| |
+ )
|
| |
+ out, err = capsys.readouterr()
|
| |
+ assert out == ""
|
| |
+ assert err == ""
|
| |