| |
@@ -21,19 +21,19 @@
|
| |
"dist_git_url": "https://src.fedoraproject.org",
|
| |
"mail_server": "bastion",
|
| |
"admin_email": "root@localhost",
|
| |
- "pdc_config": {
|
| |
- "server": "https://pdc.fedoraproject.org/rest_api/v1",
|
| |
- },
|
| |
+ "pagure_api_key": "some api key",
|
| |
+ "pagure_url": "https://src.fedoraproject.org",
|
| |
# distgit_bugzilla_sync config values
|
| |
"ignorable_accounts": [],
|
| |
"fasjson": False,
|
| |
"default_qa_contact": "nurgle@fedoraproject.org",
|
| |
"notify_admins": ["root@localhost.localdomain"],
|
| |
- "pdc_types": {
|
| |
- "rpms": "rpm",
|
| |
- },
|
| |
"products": {
|
| |
- "Fedora": {"namespace": "rpms", "versions": ["rawhide", 33, 32, 31]},
|
| |
+ "Fedora": {
|
| |
+ "branch_regex": r"^((f\d+)|rawhide)$",
|
| |
+ "namespace": "rpms",
|
| |
+ "versions": ["rawhide", 33, 32, 31],
|
| |
+ },
|
| |
"Fedora EPEL": {
|
| |
"branch_regex": r"^epel\d+$",
|
| |
"versions": ["epel9", "epel8"],
|
| |
@@ -66,6 +66,12 @@
|
| |
class TestDistgitBugzillaSyncToddler:
|
| |
toddler_cls = DistgitBugzillaSync
|
| |
|
| |
+ def setup_method(self):
|
| |
+ """
|
| |
+ Initialize toddler.
|
| |
+ """
|
| |
+ self.requests_session = Mock()
|
| |
+
|
| |
def test_accepts_topic_invalid(self, toddler):
|
| |
assert toddler.accepts_topic("foo.bar") is False
|
| |
|
| |
@@ -80,8 +86,28 @@
|
| |
def test_accepts_topic_valid(self, toddler, topic):
|
| |
assert toddler.accepts_topic(topic)
|
| |
|
| |
- def test_process_no_email_override_file(self, toddler):
|
| |
+ @patch("toddlers.plugins.distgit_bugzilla_sync.pagure.set_pagure")
|
| |
+ @patch("toddlers.plugins.distgit_bugzilla_sync.bodhi.set_bodhi")
|
| |
+ def test_process_no_email_override_file(
|
| |
+ self, mock_set_bodhi, mock_set_pagure, toddler
|
| |
+ ):
|
| |
"""Assert that the exception is raised when e-mail overrides file is not provided."""
|
| |
+ mock_dist_git = MagicMock()
|
| |
+ mock_dist_git.get_retired_packages.side_effect = (
|
| |
+ ["package01", "package02"],
|
| |
+ ["package01", "package03"],
|
| |
+ )
|
| |
+ mock_dist_git.get_branches.return_value = ["f39", "f40"]
|
| |
+ mock_dist_git.get_project.return_value = {
|
| |
+ "user": {"name": "Gavriel Loken"},
|
| |
+ "access_users": {"admin": ["Fulgrim", "orphan"]},
|
| |
+ "access_groups": {"admin": ["Adeptus Astartes"]},
|
| |
+ }
|
| |
+ mock_set_pagure.return_value = mock_dist_git
|
| |
+ mock_bodhi = MagicMock()
|
| |
+ mock_bodhi.get_active_branches.return_value = ["f39", "f40"]
|
| |
+ mock_set_bodhi.return_value = mock_bodhi
|
| |
+
|
| |
with pytest.raises(KeyError) as exc:
|
| |
toddler.process(
|
| |
config={},
|
| |
@@ -95,10 +121,14 @@
|
| |
)
|
| |
@patch("toddlers.plugins.distgit_bugzilla_sync.fedora_account")
|
| |
@patch("toddlers.plugins.distgit_bugzilla_sync.bugzilla_system")
|
| |
+ @patch("toddlers.plugins.distgit_bugzilla_sync.pagure.set_pagure")
|
| |
+ @patch("toddlers.plugins.distgit_bugzilla_sync.bodhi.set_bodhi")
|
| |
@patch("toml.load")
|
| |
def test_process_dry_run_edit_project(
|
| |
self,
|
| |
mock_toml,
|
| |
+ mock_set_bodhi,
|
| |
+ mock_set_pagure,
|
| |
mock_bugzilla,
|
| |
mock_fas,
|
| |
mock_summaries,
|
| |
@@ -121,34 +151,48 @@
|
| |
}
|
| |
response_pagure_cc = MagicMock()
|
| |
response_pagure_cc.json.return_value = {"rpms": {"foo": ["Slaanesh"]}}
|
| |
- # Mock PDC response
|
| |
- response_pdc = MagicMock()
|
| |
- response_pdc.json.return_value = {
|
| |
- "rpm": {"foo": [["f32", True], ["epel8", True]]}
|
| |
- }
|
| |
+
|
| |
toddler.requests_session.get.side_effect = (
|
| |
response_pagure_poc,
|
| |
response_pagure_cc,
|
| |
- response_pdc,
|
| |
)
|
| |
|
| |
# Mock FAS
|
| |
mock_fas.get_bz_email_user.side_effect = mock_bz_mail
|
| |
+
|
| |
# Mock bugzilla
|
| |
mock_bugzilla.get_product_info_packages.return_value = {"foo": "dummy"}
|
| |
|
| |
+ # Mock pagure
|
| |
+ mock_pagure = Mock()
|
| |
+ mock_pagure.get_branches.return_value = [
|
| |
+ "f32",
|
| |
+ "epel8",
|
| |
+ ]
|
| |
+ mock_pagure.is_retired_on_branch.return_value = False
|
| |
+ mock_set_pagure.return_value = mock_pagure
|
| |
+
|
| |
+ # Mock bodhi
|
| |
+ mock_bodhi = Mock()
|
| |
+ mock_bodhi.get_active_branches.return_value = ["f32", "epel8"]
|
| |
+ mock_set_bodhi.return_value = mock_bodhi
|
| |
+
|
| |
+ # Run test
|
| |
toddler.process(config=config, message={}, dry_run=True)
|
| |
|
| |
+ # Asserts
|
| |
mock_toml.assert_called_with("dummy_file")
|
| |
|
| |
assert toddler.namespace_to_product == {"rpms": "Fedora"}
|
| |
|
| |
assert toddler.product_to_branch_regex == {
|
| |
- "Fedora EPEL": re.compile(r"^epel\d+$")
|
| |
+ "Fedora": re.compile(r"^((f\d+)|rawhide)$"),
|
| |
+ "Fedora EPEL": re.compile(r"^epel\d+$"),
|
| |
}
|
| |
|
| |
assert toddler.branch_regex_to_product == {
|
| |
- re.compile(r"^epel\d+$"): "Fedora EPEL"
|
| |
+ re.compile(r"^epel\d+$"): "Fedora EPEL",
|
| |
+ re.compile(r"^((f\d+)|rawhide)$"): "Fedora",
|
| |
}
|
| |
|
| |
assert len(toddler.errors) == 0
|
| |
@@ -158,9 +202,13 @@
|
| |
assert toddler.requests_session.get.mock_calls == [
|
| |
call(config["dist_git_url"] + "/extras/pagure_poc.json", timeout=120),
|
| |
call(config["dist_git_url"] + "/extras/pagure_bz.json", timeout=120),
|
| |
- call("https://pdc.fedoraproject.org/extras/active_branches.json"),
|
| |
]
|
| |
|
| |
+ mock_pagure.get_branches.assert_called_once_with("rpms", "foo")
|
| |
+
|
| |
+ # One call for each product
|
| |
+ mock_bodhi.get_active_branches.call_count == 2
|
| |
+
|
| |
assert toddler.pagure_projects == [
|
| |
{
|
| |
"namespace": "rpms",
|
| |
@@ -169,7 +217,7 @@
|
| |
"epelpoc": "Tzeentch",
|
| |
"watchers": ["Slaanesh"],
|
| |
"summary": "Summary",
|
| |
- "branches": [["f32", True], ["epel8", True]],
|
| |
+ "branches": ["f32", "epel8"],
|
| |
"products": [
|
| |
"Fedora",
|
| |
"Fedora EPEL",
|
| |
@@ -234,10 +282,14 @@
|
| |
)
|
| |
@patch("toddlers.plugins.distgit_bugzilla_sync.fedora_account")
|
| |
@patch("toddlers.plugins.distgit_bugzilla_sync.bugzilla_system")
|
| |
+ @patch("toddlers.plugins.distgit_bugzilla_sync.pagure.set_pagure")
|
| |
+ @patch("toddlers.plugins.distgit_bugzilla_sync.bodhi.set_bodhi")
|
| |
@patch("toml.load")
|
| |
def test_process_dry_run_add_project(
|
| |
self,
|
| |
mock_toml,
|
| |
+ mock_set_bodhi,
|
| |
+ mock_set_pagure,
|
| |
mock_bugzilla,
|
| |
mock_fas,
|
| |
mock_summaries,
|
| |
@@ -260,15 +312,10 @@
|
| |
}
|
| |
response_pagure_cc = MagicMock()
|
| |
response_pagure_cc.json.return_value = {"rpms": {"foo": ["Slaanesh"]}}
|
| |
- # Mock PDC response
|
| |
- response_pdc = MagicMock()
|
| |
- response_pdc.json.return_value = {
|
| |
- "rpm": {"foo": [["f32", True], ["epel8", True]]}
|
| |
- }
|
| |
+
|
| |
toddler.requests_session.get.side_effect = (
|
| |
response_pagure_poc,
|
| |
response_pagure_cc,
|
| |
- response_pdc,
|
| |
)
|
| |
|
| |
# Mock FAS
|
| |
@@ -277,18 +324,36 @@
|
| |
# Mock bugzilla
|
| |
mock_bugzilla.get_product_info_packages.return_value = {}
|
| |
|
| |
+ # Mock pagure
|
| |
+ mock_pagure = Mock()
|
| |
+ mock_pagure.get_branches.return_value = [
|
| |
+ "f32",
|
| |
+ "epel8",
|
| |
+ ]
|
| |
+ mock_pagure.is_retired_on_branch.return_value = False
|
| |
+ mock_set_pagure.return_value = mock_pagure
|
| |
+
|
| |
+ # Mock bodhi
|
| |
+ mock_bodhi = Mock()
|
| |
+ mock_bodhi.get_active_branches.return_value = ["f32", "epel8"]
|
| |
+ mock_set_bodhi.return_value = mock_bodhi
|
| |
+
|
| |
+ # Run test
|
| |
toddler.process(config=config, message={}, dry_run=True)
|
| |
|
| |
+ # Asserts
|
| |
mock_toml.assert_called_with("dummy_file")
|
| |
|
| |
assert toddler.namespace_to_product == {"rpms": "Fedora"}
|
| |
|
| |
assert toddler.product_to_branch_regex == {
|
| |
- "Fedora EPEL": re.compile(r"^epel\d+$")
|
| |
+ "Fedora": re.compile(r"^((f\d+)|rawhide)$"),
|
| |
+ "Fedora EPEL": re.compile(r"^epel\d+$"),
|
| |
}
|
| |
|
| |
assert toddler.branch_regex_to_product == {
|
| |
- re.compile(r"^epel\d+$"): "Fedora EPEL"
|
| |
+ re.compile(r"^epel\d+$"): "Fedora EPEL",
|
| |
+ re.compile(r"^((f\d+)|rawhide)$"): "Fedora",
|
| |
}
|
| |
|
| |
assert len(toddler.errors) == 0
|
| |
@@ -298,7 +363,6 @@
|
| |
assert toddler.requests_session.get.mock_calls == [
|
| |
call(config["dist_git_url"] + "/extras/pagure_poc.json", timeout=120),
|
| |
call(config["dist_git_url"] + "/extras/pagure_bz.json", timeout=120),
|
| |
- call("https://pdc.fedoraproject.org/extras/active_branches.json"),
|
| |
]
|
| |
|
| |
assert toddler.pagure_projects == [
|
| |
@@ -309,7 +373,7 @@
|
| |
"epelpoc": "Tzeentch",
|
| |
"watchers": ["Slaanesh"],
|
| |
"summary": "Summary",
|
| |
- "branches": [["f32", True], ["epel8", True]],
|
| |
+ "branches": ["f32", "epel8"],
|
| |
"products": [
|
| |
"Fedora",
|
| |
"Fedora EPEL",
|
| |
@@ -370,10 +434,14 @@
|
| |
)
|
| |
@patch("toddlers.plugins.distgit_bugzilla_sync.fedora_account")
|
| |
@patch("toddlers.plugins.distgit_bugzilla_sync.bugzilla_system")
|
| |
+ @patch("toddlers.plugins.distgit_bugzilla_sync.pagure.set_pagure")
|
| |
+ @patch("toddlers.plugins.distgit_bugzilla_sync.bodhi.set_bodhi")
|
| |
@patch("toml.load")
|
| |
def test_process_dry_run_specific_project(
|
| |
self,
|
| |
mock_toml,
|
| |
+ mock_set_bodhi,
|
| |
+ mock_set_pagure,
|
| |
mock_bugzilla,
|
| |
mock_fas,
|
| |
mock_summaries,
|
| |
@@ -407,18 +475,9 @@
|
| |
"bar": ["Slaanesh"],
|
| |
}
|
| |
}
|
| |
- # Mock PDC response
|
| |
- response_pdc = MagicMock()
|
| |
- response_pdc.json.return_value = {
|
| |
- "rpm": {
|
| |
- "foo": [["f32", True], ["epel8", True]],
|
| |
- "bar": [["f32", True], ["epel8", True]],
|
| |
- }
|
| |
- }
|
| |
toddler.requests_session.get.side_effect = (
|
| |
response_pagure_poc,
|
| |
response_pagure_cc,
|
| |
- response_pdc,
|
| |
)
|
| |
|
| |
# Mock FAS
|
| |
@@ -427,7 +486,24 @@
|
| |
# Mock bugzilla
|
| |
mock_bugzilla.get_product_info_packages.return_value = {}
|
| |
|
| |
+ # Mock pagure
|
| |
+ mock_pagure = Mock()
|
| |
+ mock_pagure.get_branches.return_value = [
|
| |
+ "f32",
|
| |
+ "epel8",
|
| |
+ ]
|
| |
+ mock_pagure.is_retired_on_branch.return_value = False
|
| |
+ mock_set_pagure.return_value = mock_pagure
|
| |
+
|
| |
+ # Mock bodhi
|
| |
+ mock_bodhi = Mock()
|
| |
+ mock_bodhi.get_active_branches.return_value = ["f32", "epel8"]
|
| |
+ mock_set_bodhi.return_value = mock_bodhi
|
| |
+
|
| |
+ # Run test
|
| |
toddler.process(config=config, message={}, projects=["rpms/foo"], dry_run=True)
|
| |
+
|
| |
+ # Asserts
|
| |
assert toddler.pagure_projects == [
|
| |
{
|
| |
"namespace": "rpms",
|
| |
@@ -436,7 +512,7 @@
|
| |
"epelpoc": "Tzeentch",
|
| |
"watchers": ["Slaanesh"],
|
| |
"summary": "Summary",
|
| |
- "branches": [["f32", True], ["epel8", True]],
|
| |
+ "branches": ["f32", "epel8"],
|
| |
"products": [
|
| |
"Fedora",
|
| |
"Fedora EPEL",
|
| |
@@ -493,10 +569,14 @@
|
| |
@patch("toddlers.plugins.distgit_bugzilla_sync.fedora_account")
|
| |
@patch("toddlers.plugins.distgit_bugzilla_sync.bugzilla_system")
|
| |
@patch("toddlers.plugins.distgit_bugzilla_sync.notify")
|
| |
+ @patch("toddlers.plugins.distgit_bugzilla_sync.pagure.set_pagure")
|
| |
+ @patch("toddlers.plugins.distgit_bugzilla_sync.bodhi.set_bodhi")
|
| |
@patch("toml.load")
|
| |
def test_process_report_protocol_error(
|
| |
self,
|
| |
mock_toml,
|
| |
+ mock_set_bodhi,
|
| |
+ mock_set_pagure,
|
| |
mock_notify,
|
| |
mock_bugzilla,
|
| |
mock_fas,
|
| |
@@ -508,6 +588,7 @@
|
| |
"""Assert that `xmlrpc.client.ProtocolError` is reported correctly."""
|
| |
# Adjust config
|
| |
config["temp_folder"] = tmpdir
|
| |
+
|
| |
# Mock toml load
|
| |
email_overrides = Mock()
|
| |
mock_toml.return_value = email_overrides
|
| |
@@ -529,15 +610,9 @@
|
| |
"foo": ["Slaanesh"],
|
| |
}
|
| |
}
|
| |
- # Mock PDC response
|
| |
- response_pdc = MagicMock()
|
| |
- response_pdc.json.return_value = {
|
| |
- "rpm": {"foo": [["f32", True], ["epel8", True]]}
|
| |
- }
|
| |
toddler.requests_session.get.side_effect = (
|
| |
response_pagure_poc,
|
| |
response_pagure_cc,
|
| |
- response_pdc,
|
| |
)
|
| |
|
| |
# Mock FAS
|
| |
@@ -551,9 +626,24 @@
|
| |
"The name khorne@fedoraproject.org is not a valid username",
|
| |
{},
|
| |
)
|
| |
+ # Mock pagure
|
| |
+ mock_pagure = Mock()
|
| |
+ mock_pagure.get_branches.return_value = [
|
| |
+ "f32",
|
| |
+ "epel8",
|
| |
+ ]
|
| |
+ mock_pagure.is_retired_on_branch.return_value = False
|
| |
+ mock_set_pagure.return_value = mock_pagure
|
| |
+
|
| |
+ # Mock bodhi
|
| |
+ mock_bodhi = Mock()
|
| |
+ mock_bodhi.get_active_branches.return_value = ["f32", "epel8"]
|
| |
+ mock_set_bodhi.return_value = mock_bodhi
|
| |
|
| |
+ # Run test
|
| |
toddler.process(config=config, message={}, dry_run=False)
|
| |
|
| |
+ # Asserts
|
| |
assert mock_bugzilla.add_component.mock_calls == [
|
| |
call(
|
| |
product="Fedora",
|
| |
@@ -581,7 +671,6 @@
|
| |
"The name khorne@fedoraproject.org is not a valid username>\n"
|
| |
" ()"
|
| |
],
|
| |
- "PDC": [],
|
| |
"configuration": [],
|
| |
"mails": [],
|
| |
}
|
| |
@@ -606,10 +695,14 @@
|
| |
@patch("toddlers.plugins.distgit_bugzilla_sync.fedora_account")
|
| |
@patch("toddlers.plugins.distgit_bugzilla_sync.bugzilla_system")
|
| |
@patch("toddlers.plugins.distgit_bugzilla_sync.notify")
|
| |
+ @patch("toddlers.plugins.distgit_bugzilla_sync.pagure.set_pagure")
|
| |
+ @patch("toddlers.plugins.distgit_bugzilla_sync.bodhi.set_bodhi")
|
| |
@patch("toml.load")
|
| |
def test_process_report_client_error(
|
| |
self,
|
| |
mock_toml,
|
| |
+ mock_set_bodhi,
|
| |
+ mock_set_pagure,
|
| |
mock_notify,
|
| |
mock_bugzilla,
|
| |
mock_fas,
|
| |
@@ -621,6 +714,7 @@
|
| |
"""Assert that `xmlrpc.client.Error` is reported correctly."""
|
| |
# Adjust config
|
| |
config["temp_folder"] = tmpdir
|
| |
+
|
| |
# Mock toml load
|
| |
email_overrides = Mock()
|
| |
mock_toml.return_value = email_overrides
|
| |
@@ -642,15 +736,9 @@
|
| |
"foo": ["Slaanesh"],
|
| |
}
|
| |
}
|
| |
- # Mock PDC response
|
| |
- response_pdc = MagicMock()
|
| |
- response_pdc.json.return_value = {
|
| |
- "rpm": {"foo": [["f32", True], ["epel8", True]]}
|
| |
- }
|
| |
toddler.requests_session.get.side_effect = (
|
| |
response_pagure_poc,
|
| |
response_pagure_cc,
|
| |
- response_pdc,
|
| |
)
|
| |
|
| |
# Mock FAS
|
| |
@@ -662,8 +750,24 @@
|
| |
"The name khorne@fedoraproject.org is not a valid username"
|
| |
)
|
| |
|
| |
+ # Mock pagure
|
| |
+ mock_pagure = Mock()
|
| |
+ mock_pagure.get_branches.return_value = [
|
| |
+ "f32",
|
| |
+ "epel8",
|
| |
+ ]
|
| |
+ mock_pagure.is_retired_on_branch.return_value = False
|
| |
+ mock_set_pagure.return_value = mock_pagure
|
| |
+
|
| |
+ # Mock bodhi
|
| |
+ mock_bodhi = Mock()
|
| |
+ mock_bodhi.get_active_branches.return_value = ["f32", "epel8"]
|
| |
+ mock_set_bodhi.return_value = mock_bodhi
|
| |
+
|
| |
+ # Run test
|
| |
toddler.process(config=config, message={}, dry_run=False)
|
| |
|
| |
+ # Assert
|
| |
assert mock_bugzilla.add_component.mock_calls == [
|
| |
call(
|
| |
product="Fedora",
|
| |
@@ -712,7 +816,6 @@
|
| |
" Error('The name khorne@fedoraproject.org is not a valid username')\n"
|
| |
" ('The name khorne@fedoraproject.org is not a valid username',)",
|
| |
],
|
| |
- "PDC": [],
|
| |
"configuration": [],
|
| |
"mails": [],
|
| |
}
|
| |
@@ -739,10 +842,14 @@
|
| |
@patch("toddlers.plugins.distgit_bugzilla_sync.fedora_account")
|
| |
@patch("toddlers.plugins.distgit_bugzilla_sync.bugzilla_system")
|
| |
@patch("toddlers.plugins.distgit_bugzilla_sync.notify")
|
| |
+ @patch("toddlers.plugins.distgit_bugzilla_sync.pagure.set_pagure")
|
| |
+ @patch("toddlers.plugins.distgit_bugzilla_sync.bodhi.set_bodhi")
|
| |
@patch("toml.load")
|
| |
def test_process_report_missing_mails(
|
| |
self,
|
| |
mock_toml,
|
| |
+ mock_set_bodhi,
|
| |
+ mock_set_pagure,
|
| |
mock_notify,
|
| |
mock_bugzilla,
|
| |
mock_fas,
|
| |
@@ -789,8 +896,24 @@
|
| |
# Mock bugzilla
|
| |
mock_bugzilla.get_product_info_packages.return_value = {}
|
| |
|
| |
+ # Mock pagure
|
| |
+ mock_pagure = Mock()
|
| |
+ mock_pagure.get_branches.return_value = [
|
| |
+ "f32",
|
| |
+ "epel8",
|
| |
+ ]
|
| |
+ mock_pagure.is_retired_on_branch.return_value = False
|
| |
+ mock_set_pagure.return_value = mock_pagure
|
| |
+
|
| |
+ # Mock bodhi
|
| |
+ mock_bodhi = Mock()
|
| |
+ mock_bodhi.get_active_branches.return_value = ["f32", "epel8"]
|
| |
+ mock_set_bodhi.return_value = mock_bodhi
|
| |
+
|
| |
+ # Run test
|
| |
toddler.process(config=config, message={}, dry_run=False)
|
| |
|
| |
+ # Asserts
|
| |
assert mock_bugzilla.add_component.mock_calls == [
|
| |
call(
|
| |
product="Fedora EPEL",
|
| |
@@ -808,7 +931,6 @@
|
| |
|
| |
assert toddler.errors == {
|
| |
"bugzilla": [],
|
| |
- "PDC": [],
|
| |
"configuration": [],
|
| |
"mails": [
|
| |
"`Slaanesh` has no bugzilla_email or mailing_list set on `Fedora/foo`",
|
| |
@@ -835,10 +957,14 @@
|
| |
)
|
| |
@patch("toddlers.plugins.distgit_bugzilla_sync.fedora_account")
|
| |
@patch("toddlers.plugins.distgit_bugzilla_sync.bugzilla_system")
|
| |
+ @patch("toddlers.plugins.distgit_bugzilla_sync.pagure.set_pagure")
|
| |
+ @patch("toddlers.plugins.distgit_bugzilla_sync.bodhi.set_bodhi")
|
| |
@patch("toml.load")
|
| |
def test_process_dry_run_verbose(
|
| |
self,
|
| |
mock_toml,
|
| |
+ mock_set_bodhi,
|
| |
+ mock_set_pagure,
|
| |
mock_bugzilla,
|
| |
mock_fas,
|
| |
mock_summaries,
|
| |
@@ -862,15 +988,9 @@
|
| |
}
|
| |
response_pagure_cc = MagicMock()
|
| |
response_pagure_cc.json.return_value = {"rpms": {"foo": ["Slaanesh"]}}
|
| |
- # Mock PDC response
|
| |
- response_pdc = MagicMock()
|
| |
- response_pdc.json.return_value = {
|
| |
- "rpm": {"foo": [["f32", True], ["epel8", True]]}
|
| |
- }
|
| |
toddler.requests_session.get.side_effect = (
|
| |
response_pagure_poc,
|
| |
response_pagure_cc,
|
| |
- response_pdc,
|
| |
)
|
| |
|
| |
# Mock FAS
|
| |
@@ -879,9 +999,25 @@
|
| |
# Mock bugzilla
|
| |
mock_bugzilla.get_product_info_packages.return_value = {"foo": "dummy"}
|
| |
|
| |
+ # Mock pagure
|
| |
+ mock_pagure = Mock()
|
| |
+ mock_pagure.get_branches.return_value = [
|
| |
+ "f32",
|
| |
+ "epel8",
|
| |
+ ]
|
| |
+ mock_pagure.is_retired_on_branch.return_value = False
|
| |
+ mock_set_pagure.return_value = mock_pagure
|
| |
+
|
| |
+ # Mock bodhi
|
| |
+ mock_bodhi = Mock()
|
| |
+ mock_bodhi.get_active_branches.return_value = ["f32", "epel8"]
|
| |
+ mock_set_bodhi.return_value = mock_bodhi
|
| |
+
|
| |
+ # Run test
|
| |
with caplog.at_level(logging.DEBUG):
|
| |
toddler.process(config=config, message={}, dry_run=True)
|
| |
|
| |
+ # Asserts
|
| |
assert "Building a cache of the rpm package summaries" in caplog.text
|
| |
|
| |
assert (
|
| |
@@ -898,8 +1034,6 @@
|
| |
in caplog.text
|
| |
)
|
| |
|
| |
- assert "Querying PDC for EOL information." in caplog.text
|
| |
-
|
| |
assert "Building bugzilla's products in-memory cache" in caplog.text
|
| |
|
| |
assert "Querying bugzilla but not doing anything" in caplog.text
|
| |
@@ -932,10 +1066,14 @@
|
| |
)
|
| |
@patch("toddlers.plugins.distgit_bugzilla_sync.fedora_account")
|
| |
@patch("toddlers.plugins.distgit_bugzilla_sync.bugzilla_system")
|
| |
+ @patch("toddlers.plugins.distgit_bugzilla_sync.pagure.set_pagure")
|
| |
+ @patch("toddlers.plugins.distgit_bugzilla_sync.bodhi.set_bodhi")
|
| |
@patch("toml.load")
|
| |
def test_process_missing_namespace(
|
| |
self,
|
| |
mock_toml,
|
| |
+ mock_set_bodhi,
|
| |
+ mock_set_pagure,
|
| |
mock_bugzilla,
|
| |
mock_fas,
|
| |
mock_summaries,
|
| |
@@ -958,15 +1096,9 @@
|
| |
}
|
| |
response_pagure_cc = MagicMock()
|
| |
response_pagure_cc.json.return_value = {"modules": {"foo": ["Slaanesh"]}}
|
| |
- # Mock PDC response
|
| |
- response_pdc = MagicMock()
|
| |
- response_pdc.json.return_value = {
|
| |
- "rpm": {"foo": [["f32", True], ["epel8", True]]}
|
| |
- }
|
| |
toddler.requests_session.get.side_effect = (
|
| |
response_pagure_poc,
|
| |
response_pagure_cc,
|
| |
- response_pdc,
|
| |
)
|
| |
|
| |
# Mock FAS
|
| |
@@ -975,67 +1107,20 @@
|
| |
# Mock bugzilla
|
| |
mock_bugzilla.get_product_info_packages.return_value = {"foo": "dummy"}
|
| |
|
| |
- toddler.process(config=config, message={}, dry_run=True)
|
| |
-
|
| |
- mock_bugzilla.edit_component.assert_not_called()
|
| |
-
|
| |
- @patch(
|
| |
- "toddlers.plugins.distgit_bugzilla_sync.PackageSummaries.get_package_summaries"
|
| |
- )
|
| |
- @patch("toddlers.plugins.distgit_bugzilla_sync.fedora_account")
|
| |
- @patch("toddlers.plugins.distgit_bugzilla_sync.bugzilla_system")
|
| |
- @patch("toml.load")
|
| |
- def test_process_missing_pdc_branches(
|
| |
- self,
|
| |
- mock_toml,
|
| |
- mock_bugzilla,
|
| |
- mock_fas,
|
| |
- mock_summaries,
|
| |
- config,
|
| |
- toddler,
|
| |
- ):
|
| |
- """Assert that dry run with edit is processed correctly."""
|
| |
- # Mock toml load
|
| |
- email_overrides = Mock()
|
| |
- mock_toml.return_value = email_overrides
|
| |
-
|
| |
- # Mock package summaries response
|
| |
- mock_summaries.return_value = {"foo": "Summary"}
|
| |
+ # Mock pagure
|
| |
+ mock_pagure = Mock()
|
| |
+ mock_pagure.get_branches.return_value = []
|
| |
+ mock_set_pagure.return_value = mock_pagure
|
| |
|
| |
- # Mock pagure responses
|
| |
- toddler.requests_session = Mock()
|
| |
- response_pagure_poc = MagicMock()
|
| |
- response_pagure_poc.json.return_value = {
|
| |
- "rpms": {"foo": {"fedora": "Khorne", "epel": "Tzeentch"}}
|
| |
- }
|
| |
- response_pagure_cc = MagicMock()
|
| |
- response_pagure_cc.json.return_value = {"rpms": {"foo": ["Slaanesh"]}}
|
| |
- # Mock PDC response
|
| |
- response_pdc = MagicMock()
|
| |
- response_pdc.json.return_value = {}
|
| |
- toddler.requests_session.get.side_effect = (
|
| |
- response_pagure_poc,
|
| |
- response_pagure_cc,
|
| |
- response_pdc,
|
| |
- )
|
| |
-
|
| |
- # Mock FAS
|
| |
- mock_fas.get_bz_email_user.side_effect = mock_bz_mail
|
| |
-
|
| |
- # Mock bugzilla
|
| |
- mock_bugzilla.get_product_info_packages.return_value = {"foo": "dummy"}
|
| |
+ # Mock bodhi
|
| |
+ mock_bodhi = Mock()
|
| |
+ mock_bodhi.get_active_branches.return_value = ["f32", "epel8"]
|
| |
+ mock_set_bodhi.return_value = mock_bodhi
|
| |
|
| |
+ # Run test
|
| |
toddler.process(config=config, message={}, dry_run=True)
|
| |
|
| |
- assert toddler.errors == {
|
| |
- "bugzilla": [],
|
| |
- "PDC": [
|
| |
- "No PDC branch found for rpms/foo",
|
| |
- ],
|
| |
- "configuration": [],
|
| |
- "mails": [],
|
| |
- }
|
| |
-
|
| |
+ # Asserts
|
| |
mock_bugzilla.edit_component.assert_not_called()
|
| |
|
| |
@patch(
|
| |
@@ -1043,10 +1128,14 @@
|
| |
)
|
| |
@patch("toddlers.plugins.distgit_bugzilla_sync.fedora_account")
|
| |
@patch("toddlers.plugins.distgit_bugzilla_sync.bugzilla_system")
|
| |
+ @patch("toddlers.plugins.distgit_bugzilla_sync.pagure.set_pagure")
|
| |
+ @patch("toddlers.plugins.distgit_bugzilla_sync.bodhi.set_bodhi")
|
| |
@patch("toml.load")
|
| |
def test_process_orphaned_project(
|
| |
self,
|
| |
mock_toml,
|
| |
+ mock_set_bodhi,
|
| |
+ mock_set_pagure,
|
| |
mock_bugzilla,
|
| |
mock_fas,
|
| |
mock_summaries,
|
| |
@@ -1069,17 +1158,9 @@
|
| |
}
|
| |
response_pagure_cc = MagicMock()
|
| |
response_pagure_cc.json.return_value = {"rpms": {"foo": ["@Chaos"]}}
|
| |
- # Mock PDC response
|
| |
- response_pdc = MagicMock()
|
| |
- response_pdc.json.return_value = {
|
| |
- "rpm": {
|
| |
- "foo": [["f32", False], ["epel8", False]],
|
| |
- }
|
| |
- }
|
| |
toddler.requests_session.get.side_effect = (
|
| |
response_pagure_poc,
|
| |
response_pagure_cc,
|
| |
- response_pdc,
|
| |
)
|
| |
|
| |
# Mock FAS
|
| |
@@ -1089,8 +1170,24 @@
|
| |
# Mock bugzilla
|
| |
mock_bugzilla.get_product_info_packages.return_value = {"foo": "dummy"}
|
| |
|
| |
+ # Mock pagure
|
| |
+ mock_pagure = Mock()
|
| |
+ mock_pagure.get_branches.return_value = [
|
| |
+ "f32",
|
| |
+ "epel8",
|
| |
+ ]
|
| |
+ mock_pagure.is_retired_on_branch.return_value = True
|
| |
+ mock_set_pagure.return_value = mock_pagure
|
| |
+
|
| |
+ # Mock bodhi
|
| |
+ mock_bodhi = Mock()
|
| |
+ mock_bodhi.get_active_branches.return_value = ["f32", "epel8"]
|
| |
+ mock_set_bodhi.return_value = mock_bodhi
|
| |
+
|
| |
+ # Run test
|
| |
toddler.process(config=config, message={}, dry_run=True)
|
| |
|
| |
+ # Asserts
|
| |
assert toddler.pagure_projects == [
|
| |
{
|
| |
"namespace": "rpms",
|
| |
@@ -1099,7 +1196,7 @@
|
| |
"epelpoc": "Tzeentch",
|
| |
"watchers": ["@Chaos"],
|
| |
"summary": "Summary",
|
| |
- "branches": [["f32", False], ["epel8", False]],
|
| |
+ "branches": ["f32", "epel8"],
|
| |
"products": [
|
| |
"Fedora",
|
| |
"Fedora EPEL",
|
| |
@@ -1115,6 +1212,11 @@
|
| |
}
|
| |
]
|
| |
|
| |
+ mock_pagure.is_retired_on_branch.calls == [
|
| |
+ call("foo", "f32"),
|
| |
+ call("foo", "epel8"),
|
| |
+ ]
|
| |
+
|
| |
assert mock_bugzilla.edit_component.mock_calls == [
|
| |
call(
|
| |
owner="orphan@fedoraproject.org",
|
| |
@@ -1157,6 +1259,8 @@
|
| |
@patch(
|
| |
"toddlers.plugins.distgit_bugzilla_sync.PackageSummaries.get_package_summaries"
|
| |
)
|
| |
+ @patch("toddlers.plugins.distgit_bugzilla_sync.pagure.set_pagure")
|
| |
+ @patch("toddlers.plugins.distgit_bugzilla_sync.bodhi.set_bodhi")
|
| |
@patch("toddlers.plugins.distgit_bugzilla_sync.fedora_account")
|
| |
@patch("toddlers.plugins.distgit_bugzilla_sync.bugzilla_system")
|
| |
@patch("toml.load")
|
| |
@@ -1165,6 +1269,8 @@
|
| |
mock_toml,
|
| |
mock_bugzilla,
|
| |
mock_fas,
|
| |
+ mock_set_bodhi,
|
| |
+ mock_set_pagure,
|
| |
mock_summaries,
|
| |
config,
|
| |
toddler,
|
| |
@@ -1179,6 +1285,22 @@
|
| |
# Mock package summaries response
|
| |
mock_summaries.return_value = {"foo": "Summary"}
|
| |
|
| |
+ mock_dist_git = MagicMock()
|
| |
+ mock_dist_git.get_retired_packages.side_effect = (
|
| |
+ ["package01", "package02"],
|
| |
+ ["package01", "package03"],
|
| |
+ )
|
| |
+ mock_dist_git.get_branches.return_value = ["f39", "f40"]
|
| |
+ mock_dist_git.get_project.return_value = {
|
| |
+ "user": {"name": "Gavriel Loken"},
|
| |
+ "access_users": {"admin": ["Fulgrim", "orphan"]},
|
| |
+ "access_groups": {"admin": ["Adeptus Astartes"]},
|
| |
+ }
|
| |
+ mock_set_pagure.return_value = mock_dist_git
|
| |
+ mock_bodhi = MagicMock()
|
| |
+ mock_bodhi.get_active_branches.return_value = ["f39", "f40"]
|
| |
+ mock_set_bodhi.return_value = mock_bodhi
|
| |
+
|
| |
# Mock pagure responses
|
| |
toddler.requests_session = Mock()
|
| |
response_pagure_poc = MagicMock()
|
| |
@@ -1187,17 +1309,9 @@
|
| |
}
|
| |
response_pagure_cc = MagicMock()
|
| |
response_pagure_cc.json.return_value = {"rpms": {"foo": ["Slaanesh"]}}
|
| |
- # Mock PDC response
|
| |
- response_pdc = MagicMock()
|
| |
- response_pdc.json.return_value = {
|
| |
- "rpm": {
|
| |
- "foo": [["f32", True], ["epel8", True]],
|
| |
- }
|
| |
- }
|
| |
toddler.requests_session.get.side_effect = (
|
| |
response_pagure_poc,
|
| |
response_pagure_cc,
|
| |
- response_pdc,
|
| |
)
|
| |
|
| |
# Mock FAS
|
| |
@@ -1206,8 +1320,24 @@
|
| |
# Mock bugzilla
|
| |
mock_bugzilla.get_product_info_packages.return_value = {"foo": "dummy"}
|
| |
|
| |
+ # Mock pagure
|
| |
+ mock_pagure = Mock()
|
| |
+ mock_pagure.get_branches.return_value = [
|
| |
+ "f32",
|
| |
+ "epel8",
|
| |
+ ]
|
| |
+ mock_pagure.is_retired_on_branch.return_value = False
|
| |
+ mock_set_pagure.return_value = mock_pagure
|
| |
+
|
| |
+ # Mock bodhi
|
| |
+ mock_bodhi = Mock()
|
| |
+ mock_bodhi.get_active_branches.return_value = ["f32", "epel8"]
|
| |
+ mock_set_bodhi.return_value = mock_bodhi
|
| |
+
|
| |
+ # Run test
|
| |
toddler.process(config=config, message={}, dry_run=True)
|
| |
|
| |
+ # Asserts
|
| |
assert mock_bugzilla.edit_component.mock_calls == [
|
| |
call(
|
| |
owner="khorne@fedoraproject.org",
|
| |
@@ -1251,10 +1381,14 @@
|
| |
@patch("toddlers.plugins.distgit_bugzilla_sync.fedora_account")
|
| |
@patch("toddlers.plugins.distgit_bugzilla_sync.bugzilla_system")
|
| |
@patch("toddlers.plugins.distgit_bugzilla_sync.notify")
|
| |
+ @patch("toddlers.plugins.distgit_bugzilla_sync.pagure.set_pagure")
|
| |
+ @patch("toddlers.plugins.distgit_bugzilla_sync.bodhi.set_bodhi")
|
| |
@patch("toml.load")
|
| |
def test_process_notify_user_cache_exists(
|
| |
self,
|
| |
mock_toml,
|
| |
+ mock_set_bodhi,
|
| |
+ mock_set_pagure,
|
| |
mock_notify,
|
| |
mock_bugzilla,
|
| |
mock_fas,
|
| |
@@ -1299,17 +1433,9 @@
|
| |
"foo": ["Slaanesh"],
|
| |
}
|
| |
}
|
| |
- # Mock PDC response
|
| |
- response_pdc = MagicMock()
|
| |
- response_pdc.json.return_value = {
|
| |
- "rpm": {
|
| |
- "foo": [["f32", True], ["epel8", True]],
|
| |
- }
|
| |
- }
|
| |
toddler.requests_session.get.side_effect = (
|
| |
response_pagure_poc,
|
| |
response_pagure_cc,
|
| |
- response_pdc,
|
| |
)
|
| |
|
| |
# Mock FAS
|
| |
@@ -1321,8 +1447,24 @@
|
| |
"The name khorne@fedoraproject.org is not a valid username"
|
| |
)
|
| |
|
| |
+ # Mock pagure
|
| |
+ mock_pagure = Mock()
|
| |
+ mock_pagure.get_branches.return_value = [
|
| |
+ "f32",
|
| |
+ "epel8",
|
| |
+ ]
|
| |
+ mock_pagure.is_retired_on_branch.return_value = False
|
| |
+ mock_set_pagure.return_value = mock_pagure
|
| |
+
|
| |
+ # Mock bodhi
|
| |
+ mock_bodhi = Mock()
|
| |
+ mock_bodhi.get_active_branches.return_value = ["f32", "epel8"]
|
| |
+ mock_set_bodhi.return_value = mock_bodhi
|
| |
+
|
| |
+ # Run test
|
| |
toddler.process(config=config, message={}, dry_run=False)
|
| |
|
| |
+ # Asserts
|
| |
mock_notify.notify_packager_distgit_sync_error.assert_not_called()
|
| |
|
| |
with open(os.path.join(tmpdir, "user_cache.json")) as stream:
|
| |
@@ -1332,8 +1474,26 @@
|
| |
class TestMain:
|
| |
"""Test class for `toddler.plugins.distgit_bugzilla_sync.main`."""
|
| |
|
| |
- def test_main_no_args(self, capsys):
|
| |
+ @patch("toddlers.plugins.distgit_bugzilla_sync.pagure.set_pagure")
|
| |
+ @patch("toddlers.plugins.distgit_bugzilla_sync.bodhi.set_bodhi")
|
| |
+ def test_main_no_args(self, mock_set_bodhi, mock_set_pagure, capsys):
|
| |
"""Assert that help is printed if no arg is provided."""
|
| |
+ mock_dist_git = MagicMock()
|
| |
+ mock_dist_git.get_retired_packages.side_effect = (
|
| |
+ ["package01", "package02"],
|
| |
+ ["package01", "package03"],
|
| |
+ )
|
| |
+ mock_dist_git.get_branches.return_value = ["f39", "f40"]
|
| |
+ mock_dist_git.get_project.return_value = {
|
| |
+ "user": {"name": "Gavriel Loken"},
|
| |
+ "access_users": {"admin": ["Fulgrim", "orphan"]},
|
| |
+ "access_groups": {"admin": ["Adeptus Astartes"]},
|
| |
+ }
|
| |
+ mock_set_pagure.return_value = mock_dist_git
|
| |
+ mock_bodhi = MagicMock()
|
| |
+ mock_bodhi.get_active_branches.return_value = ["f39", "f40"]
|
| |
+ mock_set_bodhi.return_value = mock_bodhi
|
| |
+
|
| |
with pytest.raises(SystemExit):
|
| |
main([])
|
| |
|
| |
@@ -1346,15 +1506,19 @@
|
| |
assert err.startswith("usage:")
|
| |
assert "error: the following arguments are required:" in err
|
| |
|
| |
+ @patch("toddlers.plugins.distgit_bugzilla_sync.pagure.set_pagure")
|
| |
+ @patch("toddlers.plugins.distgit_bugzilla_sync.bodhi.set_bodhi")
|
| |
@patch("toml.load", new=Mock(return_value={}))
|
| |
- def test_main_debug(self, caplog):
|
| |
+ def test_main_debug(self, mock_set_bodhi, mock_set_pagure, caplog):
|
| |
"""Assert that debug is set correctly."""
|
| |
with pytest.raises(KeyError, match=r"'email_overrides_file'"):
|
| |
main(["test.cfg", "--debug"])
|
| |
assert "Failed to load the file containing the email-overrides" in caplog.text
|
| |
|
| |
+ @patch("toddlers.plugins.distgit_bugzilla_sync.pagure.set_pagure")
|
| |
+ @patch("toddlers.plugins.distgit_bugzilla_sync.bodhi.set_bodhi")
|
| |
@patch("toml.load", new=Mock(return_value={}))
|
| |
- def test_main(self, caplog):
|
| |
+ def test_main(self, mock_set_bodhi, mock_set_pagure, caplog):
|
| |
"""Assert that INFO log level is handled correctly."""
|
| |
with pytest.raises(KeyError, match=r"'email_overrides_file'"):
|
| |
main(["test.cfg"])
|
| |
This is the effort to get rid of PDC from distgit_bugzilla_sync toddler.