| |
@@ -3,7 +3,7 @@
|
| |
"""
|
| |
|
| |
import logging
|
| |
- from unittest.mock import MagicMock
|
| |
+ from unittest.mock import MagicMock, patch
|
| |
|
| |
import koji
|
| |
import pytest
|
| |
@@ -71,6 +71,8 @@
|
| |
"""Initialize toddler."""
|
| |
self.toddler_cls = koji_block_retired.KojiBlockRetired()
|
| |
self.toddler_cls.koji_session = MagicMock()
|
| |
+ self.toddler_cls.get_rawhide_tag = MagicMock()
|
| |
+ self.toddler_cls.get_rawhide_tag.return_value = "f41"
|
| |
|
| |
def test_no_dead_package_file(self, caplog):
|
| |
"""
|
| |
@@ -80,7 +82,11 @@
|
| |
message = MagicMock()
|
| |
message.body = {"commit": {"stats": {"files": {}}}}
|
| |
config = MagicMock()
|
| |
- config = {"koji_url": "https://example.koji.org"}
|
| |
+ config = {
|
| |
+ "koji_url": "https://example.koji.org",
|
| |
+ "principal": "principal",
|
| |
+ "keytab": "keytab",
|
| |
+ }
|
| |
self.toddler_cls.process_block_retired(config, message)
|
| |
assert caplog.records[-1].message == "No dead.package in the commit, bailing"
|
| |
|
| |
@@ -96,7 +102,11 @@
|
| |
}
|
| |
}
|
| |
config = MagicMock()
|
| |
- config = {"koji_url": "https://example.koji.org"}
|
| |
+ config = {
|
| |
+ "koji_url": "https://example.koji.org",
|
| |
+ "principal": "principal",
|
| |
+ "keytab": "keytab",
|
| |
+ }
|
| |
self.toddler_cls.process_block_retired(config, message)
|
| |
assert caplog.records[-1].message == "dead.package file was not added, bailing"
|
| |
|
| |
@@ -116,8 +126,15 @@
|
| |
}
|
| |
}
|
| |
config = MagicMock()
|
| |
- config = {"koji_url": "https://example.koji.org"}
|
| |
- self.toddler_cls.process_block_retired(config, message)
|
| |
+ config = {
|
| |
+ "koji_url": "https://example.koji.org",
|
| |
+ "principal": "principal",
|
| |
+ "keytab": "keytab",
|
| |
+ }
|
| |
+ with patch.object(
|
| |
+ self.toddler_cls, "get_rawhide_tag", MagicMock(return_value="f41")
|
| |
+ ):
|
| |
+ self.toddler_cls.process_block_retired(config, message)
|
| |
self.toddler_cls.koji_session.packageListBlock.assert_called_once_with(
|
| |
taginfo="f41",
|
| |
pkginfo="example-repo",
|
| |
@@ -138,7 +155,11 @@
|
| |
}
|
| |
}
|
| |
config = MagicMock()
|
| |
- config = {"koji_url": "https://example.koji.org"}
|
| |
+ 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",
|
| |
@@ -159,12 +180,15 @@
|
| |
}
|
| |
}
|
| |
config = MagicMock()
|
| |
- config = {"koji_url": "https://example.koji.org"}
|
| |
+ config = {
|
| |
+ "koji_url": "https://example.koji.org",
|
| |
+ "principal": "principal",
|
| |
+ "keytab": "keytab",
|
| |
+ }
|
| |
self.toddler_cls.koji_session.packageListBlock.side_effect = koji.GenericError(
|
| |
"Failed"
|
| |
)
|
| |
- with pytest.raises(koji.GenericError):
|
| |
- self.toddler_cls.process_block_retired(config, message)
|
| |
+ self.toddler_cls.process_block_retired(config, message)
|
| |
assert (
|
| |
caplog.records[-1].message
|
| |
== "Failed to block retired package example-repo on branch f38: Failed"
|
| |
@@ -184,12 +208,15 @@
|
| |
}
|
| |
}
|
| |
config = MagicMock()
|
| |
- config = {"koji_url": "https://example.stg.koji.org"}
|
| |
+ config = {
|
| |
+ "koji_url": "https://example.koji.org",
|
| |
+ "principal": "principal",
|
| |
+ "keytab": "keytab",
|
| |
+ }
|
| |
self.toddler_cls.koji_session.packageListBlock.side_effect = koji.GenericError(
|
| |
"Failed"
|
| |
)
|
| |
- with pytest.raises(koji.GenericError):
|
| |
- self.toddler_cls.process_block_retired(config, message)
|
| |
+ self.toddler_cls.process_block_retired(config, message)
|
| |
assert (
|
| |
caplog.records[-1].message
|
| |
== "Failed to block retired package example-epel-repo on branch f38: Failed"
|
| |