| |
@@ -50,7 +50,7 @@
|
| |
assert toddler.accepts_topic(topic)
|
| |
|
| |
@patch("toddlers.plugins.pdc_import_compose.PDCImportCompose._process_all_composes")
|
| |
- @patch("pdc_client.PDCClient")
|
| |
+ @patch("toddlers.plugins.pdc_import_compose.pdc_client_for_config")
|
| |
def test_process_full_dist_git(self, pdc, process_dg, toddler):
|
| |
client = Mock()
|
| |
pdc.return_value = client
|
| |
@@ -67,7 +67,7 @@
|
| |
@patch(
|
| |
"toddlers.plugins.pdc_import_compose.PDCImportCompose._process_single_compose"
|
| |
)
|
| |
- @patch("pdc_client.PDCClient")
|
| |
+ @patch("toddlers.plugins.pdc_import_compose.pdc_client_for_config")
|
| |
def test_process_single_package(self, pdc, process_dg, toddler):
|
| |
client = Mock()
|
| |
pdc.return_value = client
|
| |
@@ -83,7 +83,7 @@
|
| |
|
| |
@patch("toddlers.plugins.pdc_import_compose.PDCImportCompose._import_compose")
|
| |
@patch("toddlers.plugins.pdc_import_compose._old_composes")
|
| |
- @patch("pdc_client.PDCClient")
|
| |
+ @patch("toddlers.plugins.pdc_import_compose.pdc_client_for_config")
|
| |
def test__process_all_composes(self, pdc, old_composes, import_compose, toddler):
|
| |
client = Mock()
|
| |
pdc.return_value = client
|
| |
@@ -113,7 +113,7 @@
|
| |
|
| |
@patch("toddlers.plugins.pdc_import_compose.PDCImportCompose._import_compose")
|
| |
@patch("toddlers.plugins.pdc_import_compose._old_composes")
|
| |
- @patch("pdc_client.PDCClient")
|
| |
+ @patch("toddlers.plugins.pdc_import_compose.pdc_client_for_config")
|
| |
def test__process_all_composes_fail(
|
| |
self, pdc, old_composes, import_compose, caplog, toddler
|
| |
):
|
| |
@@ -152,7 +152,7 @@
|
| |
|
| |
@patch("toddlers.plugins.pdc_import_compose.PDCImportCompose._import_compose")
|
| |
@patch("toddlers.plugins.pdc_import_compose._old_composes")
|
| |
- @patch("pdc_client.PDCClient")
|
| |
+ @patch("toddlers.plugins.pdc_import_compose.pdc_client_for_config")
|
| |
def test__process_all_composes_fail_request(
|
| |
self, pdc, old_composes, import_compose, caplog, toddler
|
| |
):
|
| |
@@ -195,8 +195,11 @@
|
| |
== "Failed to import 'https://kojipkgs.../123' - 'https://kojipkgs/..../42' 'AHAH'"
|
| |
)
|
| |
|
| |
- @patch("pdc_client.PDCClient")
|
| |
- def test__process_single_compose_invalid_status(self, pdc, caplog, toddler):
|
| |
+ @patch("toddlers.plugins.pdc_import_compose.PDCImportCompose._import_compose")
|
| |
+ @patch("toddlers.plugins.pdc_import_compose.pdc_client_for_config")
|
| |
+ def test__process_single_compose_invalid_status(
|
| |
+ self, pdc, import_compose, caplog, toddler
|
| |
+ ):
|
| |
caplog.set_level(logging.INFO)
|
| |
client = Mock()
|
| |
pdc.return_value = client
|
| |
@@ -212,6 +215,7 @@
|
| |
msg,
|
| |
)
|
| |
|
| |
+ import_compose.assert_not_called()
|
| |
assert len(caplog.records) == 1
|
| |
assert (
|
| |
caplog.records[-1].message
|
| |
@@ -219,7 +223,39 @@
|
| |
)
|
| |
|
| |
@patch("toddlers.plugins.pdc_import_compose.PDCImportCompose._import_compose")
|
| |
- @patch("pdc_client.PDCClient")
|
| |
+ @patch("toddlers.plugins.pdc_import_compose.pdc_client_for_config")
|
| |
+ def test__process_single_compose_invalid_location(
|
| |
+ self, pdc, import_compose, caplog, toddler
|
| |
+ ):
|
| |
+ caplog.set_level(logging.INFO)
|
| |
+ client = Mock()
|
| |
+ pdc.return_value = client
|
| |
+
|
| |
+ msg = fedora_messaging.api.Message()
|
| |
+ msg.id = 123
|
| |
+ msg.topic = "org.fedoraproject.prod.pungi.compose.status.change"
|
| |
+ msg.body = {
|
| |
+ "status": "FINISHED",
|
| |
+ "compose_id": 42,
|
| |
+ "location": "/mnt/koji/compose/rawhide/42/compose",
|
| |
+ }
|
| |
+
|
| |
+ toddler._process_single_compose(
|
| |
+ {"old_composes_url": "https://kojipkgs.fedoraproject.org/compose/"},
|
| |
+ pdc,
|
| |
+ msg,
|
| |
+ )
|
| |
+
|
| |
+ import_compose.assert_not_called()
|
| |
+ assert len(caplog.records) == 1
|
| |
+ assert (
|
| |
+ caplog.records[-1].message
|
| |
+ == "The compose: 42 has nt/koji/compose/rawhide/42 for location while it must "
|
| |
+ "be an actual url for us to deal with it, bailing"
|
| |
+ )
|
| |
+
|
| |
+ @patch("toddlers.plugins.pdc_import_compose.PDCImportCompose._import_compose")
|
| |
+ @patch("toddlers.plugins.pdc_import_compose.pdc_client_for_config")
|
| |
def test__process_single_compose(self, pdc, import_compose, toddler):
|
| |
client = Mock()
|
| |
pdc.return_value = client
|
| |
@@ -499,13 +535,13 @@
|
| |
resp_composeinfo.ok = True
|
| |
resp_composeinfo.json.return_value = {
|
| |
"payload": {
|
| |
- "compose": {"id": "Fedora-Rawhide-20200715.n.2"},
|
| |
+ "compose": {"id": "Fedora-32-20200715.n.2"},
|
| |
"release": {
|
| |
"internal": False,
|
| |
"name": "Fedora",
|
| |
"short": "Fedora",
|
| |
- "type": "ga",
|
| |
- "version": "Rawhide",
|
| |
+ "type": "updates-testing",
|
| |
+ "version": "32",
|
| |
},
|
| |
}
|
| |
}
|
| |
@@ -523,32 +559,32 @@
|
| |
|
| |
toddler._import_compose(
|
| |
pdc,
|
| |
- "Fedora-Rawhide-20200715.n.2",
|
| |
- "https://kojipkgs.fedoraproject.org/compose/rawhide/Fedora-Rawhide-20200715.n.2",
|
| |
+ "Fedora-32-20200715.n.2",
|
| |
+ "https://kojipkgs.fedoraproject.org/compose/32/Fedora-32-20200715.n.2",
|
| |
)
|
| |
ensure_release_exists.assert_called_once_with(
|
| |
pdc,
|
| |
- "fedora-Rawhide",
|
| |
+ "fedora-32-updates-testing",
|
| |
{
|
| |
"name": "Fedora",
|
| |
"short": "fedora",
|
| |
- "version": "Rawhide",
|
| |
- "release_type": "ga",
|
| |
+ "version": "32",
|
| |
+ "release_type": "updates-testing",
|
| |
},
|
| |
)
|
| |
|
| |
pdc["compose-images"]._.assert_called_once_with(
|
| |
{
|
| |
- "release_id": "fedora-Rawhide",
|
| |
+ "release_id": "fedora-32-updates-testing",
|
| |
"composeinfo": {
|
| |
"payload": {
|
| |
- "compose": {"id": "Fedora-Rawhide-20200715.n.2"},
|
| |
+ "compose": {"id": "Fedora-32-20200715.n.2"},
|
| |
"release": {
|
| |
"internal": False,
|
| |
"name": "Fedora",
|
| |
"short": "fedora",
|
| |
- "type": "ga",
|
| |
- "version": "Rawhide",
|
| |
+ "type": "updates-testing",
|
| |
+ "version": "32",
|
| |
},
|
| |
}
|
| |
},
|
| |
@@ -558,16 +594,16 @@
|
| |
# It's not actually called, this is a side-effect of using Mock/MagicMock
|
| |
pdc["compose-rpms"]._.assert_called_once_with(
|
| |
{
|
| |
- "release_id": "fedora-Rawhide",
|
| |
+ "release_id": "fedora-32-updates-testing",
|
| |
"composeinfo": {
|
| |
"payload": {
|
| |
- "compose": {"id": "Fedora-Rawhide-20200715.n.2"},
|
| |
+ "compose": {"id": "Fedora-32-20200715.n.2"},
|
| |
"release": {
|
| |
"internal": False,
|
| |
"name": "Fedora",
|
| |
"short": "fedora",
|
| |
- "type": "ga",
|
| |
- "version": "Rawhide",
|
| |
+ "type": "updates-testing",
|
| |
+ "version": "32",
|
| |
},
|
| |
}
|
| |
},
|
| |
@@ -578,7 +614,7 @@
|
| |
assert (
|
| |
caplog.records[-2].message
|
| |
== "Found no rpms.json file at 'https://kojipkgs.fedoraproject.org/compose/"
|
| |
- "rawhide/Fedora-Rawhide-20200715.n.2/compose/metadata/rpms.json'"
|
| |
+ "32/Fedora-32-20200715.n.2/compose/metadata/rpms.json'"
|
| |
)
|
| |
assert caplog.records[-1].message == "Import done."
|
| |
|
| |
@@ -867,3 +903,26 @@
|
| |
caplog.records[-1].message
|
| |
== "Creating release {'foo': 'bar', 'active': True}"
|
| |
)
|
| |
+
|
| |
+ def test_ensure_release_exists_create_then_fail(self, caplog):
|
| |
+ caplog.set_level(logging.DEBUG)
|
| |
+ pdc = MagicMock()
|
| |
+ resp = Mock()
|
| |
+ resp.status_code = 404
|
| |
+ resp.text = "html content"
|
| |
+ pdc["releases"]["release-id"]._.side_effect = beanbag.bbexcept.BeanBagException(
|
| |
+ msg="Failed to do something", response=resp
|
| |
+ )
|
| |
+ pdc["releases"]._.side_effect = beanbag.bbexcept.BeanBagException(
|
| |
+ msg="Failed to create the release", response=resp
|
| |
+ )
|
| |
+
|
| |
+ with pytest.raises(
|
| |
+ beanbag.bbexcept.BeanBagException, match=r"Failed to create the release .*",
|
| |
+ ):
|
| |
+ toddlers.plugins.pdc_import_compose.ensure_release_exists(
|
| |
+ pdc, "release-id", {"foo": "bar"}
|
| |
+ )
|
| |
+ pdc["releases"]._.assert_called_once_with({"foo": "bar", "active": True})
|
| |
+ assert caplog.records[-2].message.startswith("Failed to create the release")
|
| |
+ assert caplog.records[-1].message.startswith("html content")
|
| |