Correctly handle unknown namespace in distgit_bugzilla_sync
If we can't map the namespace to product in bugzilla just skip it. Signed-off-by: Michal Konecny <mkonecny@redhat.com>
This commit is contained in:
parent
7bb1682d6f
commit
c460b777c4
2 changed files with 72 additions and 9 deletions
|
@ -277,6 +277,68 @@ class TestDistgitBugzillaSyncToddler:
|
|||
),
|
||||
]
|
||||
|
||||
@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("toddlers.plugins.distgit_bugzilla_sync.pagure.set_pagure")
|
||||
@patch("toddlers.plugins.distgit_bugzilla_sync.bodhi.set_bodhi")
|
||||
@patch("toml.load")
|
||||
def test_process_unknown_namespace(
|
||||
self,
|
||||
mock_toml,
|
||||
mock_set_bodhi,
|
||||
mock_set_pagure,
|
||||
mock_bugzilla,
|
||||
mock_fas,
|
||||
mock_summaries,
|
||||
config,
|
||||
toddler,
|
||||
):
|
||||
"""Assert that namespace that we don't know product for will be ignored."""
|
||||
# Mock toml load
|
||||
email_overrides = Mock()
|
||||
mock_toml.return_value = email_overrides
|
||||
|
||||
# Mock package summaries response
|
||||
mock_summaries.return_value = {"foo": "Summary"}
|
||||
|
||||
# Mock pagure responses
|
||||
toddler.requests_session = Mock()
|
||||
response_pagure_poc = MagicMock()
|
||||
response_pagure_poc.json.return_value = {
|
||||
"flatpaks": {"foo": {"fedora": "Khorne"}}
|
||||
}
|
||||
response_pagure_cc = MagicMock()
|
||||
response_pagure_cc.json.return_value = {"flatpaks": {"foo": ["Slaanesh"]}}
|
||||
|
||||
toddler.requests_session.get.side_effect = (
|
||||
response_pagure_poc,
|
||||
response_pagure_cc,
|
||||
)
|
||||
|
||||
# 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 len(toddler.errors) == 0
|
||||
|
||||
mock_summaries.assert_called_with(config)
|
||||
|
||||
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),
|
||||
]
|
||||
|
||||
assert toddler.pagure_projects == []
|
||||
|
||||
mock_bugzilla.assert_not_called()
|
||||
|
||||
@patch(
|
||||
"toddlers.plugins.distgit_bugzilla_sync.PackageSummaries.get_package_summaries"
|
||||
)
|
||||
|
|
|
@ -347,15 +347,16 @@ class DistgitBugzillaSync(ToddlerBase):
|
|||
for namespace, entries in pagure_namespace_to_poc.items():
|
||||
for name, poc in entries.items():
|
||||
if not project_set or (namespace, name) in project_set:
|
||||
self.pagure_projects.append(
|
||||
{
|
||||
"namespace": namespace,
|
||||
"name": name,
|
||||
"poc": poc["fedora"],
|
||||
"epelpoc": poc["epel"],
|
||||
"watchers": pagure_namespace_to_cc[namespace][name],
|
||||
}
|
||||
)
|
||||
if namespace in self.namespace_to_product:
|
||||
self.pagure_projects.append(
|
||||
{
|
||||
"namespace": namespace,
|
||||
"name": name,
|
||||
"poc": poc["fedora"],
|
||||
"epelpoc": poc["epel"],
|
||||
"watchers": pagure_namespace_to_cc[namespace][name],
|
||||
}
|
||||
)
|
||||
|
||||
def _add_branches_products_and_summaries(
|
||||
self,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue