def test_pkglist_unblock_inherited(self, lookup_package, get_tag, assert_policy, readPackageList, _pkglist_add, _pkglist_remove): tag_id, pkg_id, owner_id = 1, 2, 3 get_tag.return_value = {'id': tag_id, 'name': 'tag'} lookup_package.return_value = {'id': pkg_id, 'name': 'pkg'} readPackageList.return_value = { pkg_id: { 'blocked': True, 'tag_id': 4, 'owner_id': owner_id, 'extra_arches': '' } } kojihub.pkglist_unblock('tag', 'pkg', force=False) get_tag.assert_called_once_with('tag', strict=True) lookup_package.assert_called_once_with('pkg', strict=True) assert_policy.assert_called_once_with('package_list', { 'tag': tag_id, 'action': 'unblock', 'package': pkg_id, 'force': False }, force=False) readPackageList.assert_called_once_with(tag_id, pkgID=pkg_id, inherit=True) _pkglist_add.assert_called_once_with(tag_id, pkg_id, owner_id, False, '') _pkglist_remove.assert_not_called()
def test_pkglist_unblock_not_present(self, lookup_package, get_tag, assert_policy, readPackageList, _pkglist_add, _pkglist_remove): tag_id, pkg_id = 1, 2 get_tag.return_value = {'id': tag_id, 'name': 'tag'} lookup_package.return_value = {'id': pkg_id, 'name': 'pkg'} readPackageList.return_value = {} with self.assertRaises(koji.GenericError): kojihub.pkglist_unblock('tag', 'pkg', force=False) get_tag.assert_called_once_with('tag', strict=True) lookup_package.assert_called_once_with('pkg', strict=True) assert_policy.assert_called_once_with('package_list', { 'tag': tag_id, 'action': 'unblock', 'package': pkg_id, 'force': False }, force=False) readPackageList.assert_called_once_with(tag_id, pkgID=pkg_id, inherit=True) _pkglist_add.assert_not_called() _pkglist_remove.assert_not_called()
def test_pkglist_unblock(self, lookup_package, get_tag, assert_policy, readPackageList, _pkglist_add, _pkglist_remove): tag = {'id': 1, 'name': 'tag'} pkg = {'id': 2, 'name': 'package', 'owner_id': 3} get_tag.return_value = tag lookup_package.return_value = pkg readPackageList.return_value = {pkg['id']: { 'blocked': True, 'tag_id': tag['id'], 'owner_id': pkg['owner_id'], 'extra_arches': ''}} kojihub.pkglist_unblock('tag', 'pkg', force=False) get_tag.assert_called_once_with('tag', strict=True) lookup_package.assert_called_once_with('pkg', strict=True) assert_policy.assert_called_once_with('package_list', {'tag': tag['id'], 'action': 'unblock', 'package': pkg['id'], 'force': False}) self.assertEqual(readPackageList.call_count, 2) readPackageList.assert_has_calls([ mock.call(tag['id'], pkgID=pkg['id'], inherit=True), mock.call(tag['id'], pkgID=pkg['id'], inherit=True), ]) _pkglist_add.assert_called_once_with(tag['id'], pkg['id'], pkg['owner_id'], False, '') _pkglist_remove.assert_called_once_with(tag['id'], pkg['id']) self.assertEqual(self.run_callbacks.call_count, 2) self.run_callbacks.assert_has_calls([ mock.call('prePackageListChange', action='unblock', tag=tag, package=pkg), mock.call('postPackageListChange', action='unblock', tag=tag, package=pkg), ])
def test_pkglist_unblock(self, lookup_package, get_tag, assert_policy, readPackageList, _pkglist_add, _pkglist_remove): tag = {'id': 1, 'name': 'tag'} pkg = {'id': 2, 'name': 'package', 'owner_id': 3} get_tag.return_value = tag lookup_package.return_value = pkg readPackageList.return_value = { pkg['id']: { 'blocked': True, 'tag_id': tag['id'], 'owner_id': pkg['owner_id'], 'extra_arches': '' } } kojihub.pkglist_unblock('tag', 'pkg', force=False) get_tag.assert_called_once_with('tag', strict=True) lookup_package.assert_called_once_with('pkg', strict=True) assert_policy.assert_called_once_with('package_list', { 'tag': tag['id'], 'action': 'unblock', 'package': pkg['id'], 'force': False }, force=False) self.assertEqual(readPackageList.call_count, 2) readPackageList.assert_has_calls([ mock.call(tag['id'], pkgID=pkg['id'], inherit=True), mock.call(tag['id'], pkgID=pkg['id'], inherit=True), ]) _pkglist_add.assert_called_once_with(tag['id'], pkg['id'], pkg['owner_id'], False, '') _pkglist_remove.assert_called_once_with(tag['id'], pkg['id']) self.assertEqual(self.run_callbacks.call_count, 2) self.run_callbacks.assert_has_calls([ mock.call('prePackageListChange', action='unblock', tag=tag, package=pkg, user=None), mock.call('postPackageListChange', action='unblock', tag=tag, package=pkg, user=None), ])
def test_pkglist_unblock_not_present(self, lookup_package, get_tag, assert_policy, readPackageList, _pkglist_add, _pkglist_remove): tag_id, pkg_id = 1, 2 get_tag.return_value = {'id': tag_id, 'name': 'tag'} lookup_package.return_value = {'id': pkg_id, 'name': 'pkg'} readPackageList.return_value = {} with self.assertRaises(koji.GenericError): kojihub.pkglist_unblock('tag', 'pkg', force=False) get_tag.assert_called_once_with('tag', strict=True) lookup_package.assert_called_once_with('pkg', strict=True) assert_policy.assert_called_once_with('package_list', {'tag': tag_id, 'action': 'unblock', 'package': pkg_id, 'force': False}) readPackageList.assert_called_once_with(tag_id, pkgID=pkg_id, inherit=True) _pkglist_add.assert_not_called() _pkglist_remove.assert_not_called()
def test_pkglist_unblock_inherited(self, lookup_package, get_tag, assert_policy, readPackageList, _pkglist_add, _pkglist_remove): tag_id, pkg_id, owner_id = 1, 2, 3 get_tag.return_value = {'id': tag_id, 'name': 'tag'} lookup_package.return_value = {'id': pkg_id, 'name': 'pkg'} readPackageList.return_value = {pkg_id: { 'blocked': True, 'tag_id': 4, 'owner_id': owner_id, 'extra_arches': ''}} kojihub.pkglist_unblock('tag', 'pkg', force=False) get_tag.assert_called_once_with('tag', strict=True) lookup_package.assert_called_once_with('pkg', strict=True) assert_policy.assert_called_once_with('package_list', {'tag': tag_id, 'action': 'unblock', 'package': pkg_id, 'force': False}) readPackageList.assert_called_once_with(tag_id, pkgID=pkg_id, inherit=True) _pkglist_add.assert_called_once_with(tag_id, pkg_id, owner_id, False, '') _pkglist_remove.assert_not_called()