From da85023185b54771975afc29201ba59d25fc7e25 Mon Sep 17 00:00:00 2001 From: Mike McLean Date: May 22 2019 17:12:32 +0000 Subject: PR#1257: fail runroot task on non-existing tag Merges #1257 https://pagure.io/koji/pull-request/1257 Related: #1139 https://pagure.io/koji/issue/1139 runroot API call should raise GenericError exception for non existing tag --- diff --git a/plugins/hub/runroot_hub.py b/plugins/hub/runroot_hub.py index 708aede..4dc46f2 100644 --- a/plugins/hub/runroot_hub.py +++ b/plugins/hub/runroot_hub.py @@ -37,9 +37,9 @@ def runroot(tagInfo, arch, command, channel=None, **opts): taskopts['channel'] = channel or 'runroot' + tag = kojihub.get_tag(tagInfo, strict=True) if arch == 'noarch': #not all arches can generate a proper buildroot for all tags - tag = kojihub.get_tag(tagInfo) if not tag['arches']: raise koji.GenericError('no arches defined for tag %s' % tag['name']) diff --git a/tests/test_plugins/test_runroot_hub.py b/tests/test_plugins/test_runroot_hub.py index 637634e..dfae605 100644 --- a/tests/test_plugins/test_runroot_hub.py +++ b/tests/test_plugins/test_runroot_hub.py @@ -10,10 +10,12 @@ import runroot_hub class TestRunrootHub(unittest.TestCase): + @mock.patch('kojihub.get_tag') @mock.patch('kojihub.make_task') @mock.patch('runroot_hub.context') - def test_basic_invocation(self, context, make_task): + def test_basic_invocation(self, context, make_task, get_tag): context.session.assertPerm = mock.MagicMock() + get_tag.return_value = {'name': 'some_tag', 'arches': ''} runroot_hub.runroot( tagInfo='some_tag', arch='x86_64', @@ -38,7 +40,7 @@ class TestRunrootHub(unittest.TestCase): arch='noarch', command='ls', ) - get_tag.assert_called_once_with('some_tag') + get_tag.assert_called_once_with('some_tag', strict=True) @mock.patch('kojihub.make_task') @mock.patch('kojihub.get_all_arches') @@ -84,7 +86,7 @@ class TestRunrootHub(unittest.TestCase): ) # check results - get_tag.assert_called_once_with('some_tag') + get_tag.assert_called_once_with('some_tag', strict=True) context.handlers.call.assert_has_calls([ mock.call('getChannel', 'runroot', strict=True), mock.call('listHosts', channelID=2, enabled=True), @@ -142,7 +144,7 @@ class TestRunrootHub(unittest.TestCase): ) # check results - get_tag.assert_called_once_with('some_tag') + get_tag.assert_called_once_with('some_tag', strict=True) context.handlers.call.assert_has_calls([ mock.call('getChannel', 'runroot', strict=True), mock.call('listHosts', channelID=2, enabled=True),