| |
@@ -48,6 +48,7 @@
|
| |
def setup_method(self):
|
| |
"""Initialize toddler."""
|
| |
self.toddler_cls = koji_block_retired.KojiBlockRetired()
|
| |
+ self.toddler_cls.koji_session = MagicMock()
|
| |
|
| |
def test_process(self):
|
| |
"""
|
| |
@@ -109,14 +110,16 @@
|
| |
assert caplog.records[-1].message == "dead.package file was not added, bailing"
|
| |
|
| |
@patch("toddlers.plugins.koji_block_retired.KojiBlockRetired._create_session")
|
| |
- @patch("toddlers.plugins.koji_block_retired.KojiBlockRetired.get_rawhide_tag")
|
| |
+ @patch(
|
| |
+ "toddlers.plugins.koji_block_retired.KojiBlockRetired.get_fedora_rawhide_tag"
|
| |
+ )
|
| |
def test_dead_package_added_to_main_branch(
|
| |
- self, mock_get_rawhide_tag, mock_session, caplog
|
| |
+ self, mock_get_fedora_rawhide_tag, caplog
|
| |
):
|
| |
"""
|
| |
Assert that that main branch will be changed to rawhide tag
|
| |
"""
|
| |
- mock_get_rawhide_tag.return_value = "f41"
|
| |
+ mock_get_fedora_rawhide_tag.return_value = "f41"
|
| |
caplog.set_level(logging.INFO)
|
| |
|
| |
message = MagicMock()
|
| |
@@ -137,7 +140,7 @@
|
| |
"keytab": "keytab",
|
| |
}
|
| |
with patch.object(
|
| |
- self.toddler_cls, "get_rawhide_tag", MagicMock(return_value="f41")
|
| |
+ self.toddler_cls, "get_fedora_rawhide_tag", MagicMock(return_value="f41")
|
| |
):
|
| |
self.toddler_cls.process_block_retired(config, message)
|
| |
self.toddler_cls.koji_session.packageListBlock.assert_called_once_with(
|
| |
@@ -263,3 +266,101 @@
|
| |
caplog.records[-1].message
|
| |
== "Commit is older than 1 day, probably new branch creation, bailing."
|
| |
)
|
| |
+
|
| |
+ def test_get_fedora_rawhide_tag(self):
|
| |
+ self.toddler_cls.koji_session.getBuildTarget.return_value = {
|
| |
+ "build_tag": 94099,
|
| |
+ "build_tag_name": "f42-build",
|
| |
+ "dest_tag": 94094,
|
| |
+ "dest_tag_name": "f42-updates-candidate",
|
| |
+ "id": 88,
|
| |
+ "name": "rawhide",
|
| |
+ }
|
| |
+ assert self.toddler_cls.get_fedora_rawhide_tag(branch="rawhide") == "f42"
|
| |
+
|
| |
+ def test_get_fedora_rawhide_koji_error(self, caplog):
|
| |
+ self.toddler_cls.koji_session.getBuildTarget.side_effect = koji.GenericError(
|
| |
+ "Failed"
|
| |
+ )
|
| |
+ self.toddler_cls.get_fedora_rawhide_tag(branch="rawhide")
|
| |
+ assert (
|
| |
+ caplog.records[-1].message
|
| |
+ == "Failed to get fedora rawhide tag in koji: Failed"
|
| |
+ )
|
| |
+
|
| |
+ def test_get_epel_latest_tag(self):
|
| |
+ self.toddler_cls.koji_session.getBuildTarget.return_value = {
|
| |
+ "build_tag": 93222,
|
| |
+ "build_tag_name": "epel10.0-build",
|
| |
+ "dest_tag": 93225,
|
| |
+ "dest_tag_name": "epel10.0-testing-candidate",
|
| |
+ "id": 40886,
|
| |
+ "name": "epel10",
|
| |
+ }
|
| |
+
|
| |
+ assert self.toddler_cls.get_epel_latest_tag(branch="epel10") == "epel10.0"
|
| |
+
|
| |
+ def test_get_epel_latest_tag_koji_error(self, caplog):
|
| |
+ self.toddler_cls.koji_session.getBuildTarget.side_effect = koji.GenericError(
|
| |
+ "Failed"
|
| |
+ )
|
| |
+ self.toddler_cls.get_epel_latest_tag(branch="epel10")
|
| |
+ assert (
|
| |
+ caplog.records[-1].message
|
| |
+ == "Failed to get latest epel tag in koji: Failed"
|
| |
+ )
|
| |
+
|
| |
+ @patch("toddlers.plugins.koji_block_retired.KojiBlockRetired._create_session")
|
| |
+ def test_branch_with_container(self, mock_session, caplog):
|
| |
+ caplog.set_level(logging.INFO)
|
| |
+ message = MagicMock()
|
| |
+ message.body = {
|
| |
+ "commit": {
|
| |
+ "stats": {"files": {"dead.package": {"additions": 1, "deletions": 0}}},
|
| |
+ "branch": "f38",
|
| |
+ "repo": "example-repo",
|
| |
+ "namespace": "containers",
|
| |
+ "date": "2024-09-16T12:12:46+01:00",
|
| |
+ }
|
| |
+ }
|
| |
+ message._headers = {"sent-at": "2024-09-16T12:12:46+01:00"}
|
| |
+ config = MagicMock()
|
| |
+ config = {
|
| |
+ "koji_url": "https://example.koji.org",
|
| |
+ "principal": "principal",
|
| |
+ "keytab": "keytab",
|
| |
+ }
|
| |
+ self.toddler_cls.process_block_retired(config, message)
|
| |
+ self.toddler_cls.koji_session.packageListBlock.assert_called_once_with(
|
| |
+ taginfo="f38-container",
|
| |
+ pkginfo="example-repo",
|
| |
+ )
|
| |
+
|
| |
+ @patch("toddlers.plugins.koji_block_retired.KojiBlockRetired._create_session")
|
| |
+ @patch("toddlers.plugins.koji_block_retired.KojiBlockRetired.get_epel_latest_tag")
|
| |
+ def test_branch_epel(self, mock_get_fedora_epel_tag, mock_session, caplog):
|
| |
+ mock_get_fedora_epel_tag.return_value = "epel10.2"
|
| |
+ caplog.set_level(logging.INFO)
|
| |
+ message = MagicMock()
|
| |
+ message.body = {
|
| |
+ "commit": {
|
| |
+ "stats": {"files": {"dead.package": {"additions": 1, "deletions": 0}}},
|
| |
+ "branch": "epel10",
|
| |
+ "repo": "example-repo",
|
| |
+ "namespace": "example_ns",
|
| |
+ "date": "2024-09-16T12:12:46+01:00",
|
| |
+ }
|
| |
+ }
|
| |
+ message._headers = {"sent-at": "2024-09-16T12:12:46+01:00"}
|
| |
+ config = MagicMock()
|
| |
+
|
| |
+ config = {
|
| |
+ "koji_url": "https://example.koji.org",
|
| |
+ "principal": "principal",
|
| |
+ "keytab": "keytab",
|
| |
+ }
|
| |
+ self.toddler_cls.process_block_retired(config, message)
|
| |
+ self.toddler_cls.koji_session.packageListBlock.assert_called_once_with(
|
| |
+ taginfo="epel10.2",
|
| |
+ pkginfo="example-repo",
|
| |
+ )
|
| |
Signed-off-by: Lenka Segura lsegura@redhat.com