Remove deprecated remove-channel/removeChannel
Fixes: https://pagure.io/koji/issue/3356
This commit is contained in:
parent
9a1ee191a6
commit
52026bcfcb
6 changed files with 0 additions and 183 deletions
|
|
@ -46,7 +46,6 @@ admin commands:
|
|||
make-task Create an arbitrary task
|
||||
prune-signed-copies Prune signed copies
|
||||
regen-repo Force a repo to be regenerated
|
||||
remove-channel Remove a channel entirely
|
||||
remove-external-repo Remove an external repo from a tag or tags, or remove entirely
|
||||
remove-group Remove group from tag
|
||||
remove-host-from-channel Remove a host from a channel
|
||||
|
|
|
|||
|
|
@ -46,7 +46,6 @@ admin commands:
|
|||
make-task Create an arbitrary task
|
||||
prune-signed-copies Prune signed copies
|
||||
regen-repo Force a repo to be regenerated
|
||||
remove-channel Remove a channel entirely
|
||||
remove-external-repo Remove an external repo from a tag or tags, or remove entirely
|
||||
remove-group Remove group from tag
|
||||
remove-host-from-channel Remove a host from a channel
|
||||
|
|
|
|||
|
|
@ -1,93 +0,0 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
import unittest
|
||||
|
||||
import six
|
||||
import mock
|
||||
|
||||
from koji_cli.commands import handle_remove_channel
|
||||
from . import utils
|
||||
|
||||
|
||||
class TestRemoveChannel(utils.CliTestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.options = mock.MagicMock()
|
||||
self.session = mock.MagicMock()
|
||||
self.channel_name = 'test-channel'
|
||||
self.description = 'description'
|
||||
self.channel_info = {
|
||||
'id': 123,
|
||||
'name': self.channel_name,
|
||||
'description': self.description,
|
||||
}
|
||||
self.maxDiff = None
|
||||
|
||||
@mock.patch('sys.stdout', new_callable=six.StringIO)
|
||||
@mock.patch('koji_cli.commands.activate_session')
|
||||
def test_handle_remove_channel(self, activate_session_mock, stdout):
|
||||
self.session.getChannel.return_value = self.channel_info
|
||||
rv = handle_remove_channel(self.options, self.session, [self.channel_name])
|
||||
actual = stdout.getvalue()
|
||||
expected = 'remove-channel is deprecated and will be removed in 1.30\n'
|
||||
self.assertMultiLineEqual(actual, expected)
|
||||
activate_session_mock.assert_called_once_with(self.session, self.options)
|
||||
self.session.getChannel.assert_called_once_with(self.channel_name)
|
||||
self.session.removeChannel.assert_called_once_with(self.channel_name, force=None)
|
||||
self.assertNotEqual(rv, 1)
|
||||
|
||||
@mock.patch('sys.stdout', new_callable=six.StringIO)
|
||||
@mock.patch('koji_cli.commands.activate_session')
|
||||
def test_handle_remove_channel_force(self, activate_session_mock, stdout):
|
||||
self.session.getChannel.return_value = self.channel_info
|
||||
rv = handle_remove_channel(self.options, self.session, ['--force', self.channel_name])
|
||||
actual = stdout.getvalue()
|
||||
expected = 'remove-channel is deprecated and will be removed in 1.30\n'
|
||||
self.assertMultiLineEqual(actual, expected)
|
||||
activate_session_mock.assert_called_once_with(self.session, self.options)
|
||||
self.session.getChannel.assert_called_once_with(self.channel_name)
|
||||
self.session.removeChannel.assert_called_once_with(self.channel_name, force=True)
|
||||
self.assertNotEqual(rv, 1)
|
||||
|
||||
@mock.patch('sys.stderr', new_callable=six.StringIO)
|
||||
@mock.patch('koji_cli.commands.activate_session')
|
||||
def test_handle_remove_channel_no_channel(
|
||||
self, activate_session_mock, stderr):
|
||||
channel_info = None
|
||||
|
||||
self.session.getChannel.return_value = channel_info
|
||||
with self.assertRaises(SystemExit) as ex:
|
||||
handle_remove_channel(self.options, self.session, [self.channel_name])
|
||||
self.assertExitCode(ex, 1)
|
||||
actual = stderr.getvalue()
|
||||
expected = 'No such channel: %s\n' % self.channel_name
|
||||
self.assertMultiLineEqual(actual, expected)
|
||||
activate_session_mock.assert_called_once_with(self.session, self.options)
|
||||
self.session.getChannel.assert_called_once_with(self.channel_name)
|
||||
self.session.removeChannel.assert_not_called()
|
||||
|
||||
@mock.patch('sys.stdout', new_callable=six.StringIO)
|
||||
@mock.patch('sys.stderr', new_callable=six.StringIO)
|
||||
@mock.patch('koji_cli.commands.activate_session')
|
||||
def test_handle_remove_channel_help(
|
||||
self, activate_session_mock, stderr, stdout):
|
||||
with self.assertRaises(SystemExit) as ex:
|
||||
handle_remove_channel(self.options, self.session, [])
|
||||
self.assertExitCode(ex, 2)
|
||||
actual_stdout = stdout.getvalue()
|
||||
actual_stderr = stderr.getvalue()
|
||||
expected_stdout = 'remove-channel is deprecated and will be removed in 1.30\n'
|
||||
expected_stderr = """Usage: %s remove-channel [options] <channel>
|
||||
(Specify the --help global option for a list of other help options)
|
||||
|
||||
%s: error: Incorrect number of arguments
|
||||
""" % (self.progname, self.progname)
|
||||
self.assertMultiLineEqual(actual_stdout, expected_stdout)
|
||||
self.assertMultiLineEqual(actual_stderr, expected_stderr)
|
||||
activate_session_mock.assert_not_called()
|
||||
self.session.getChannel.assert_not_called()
|
||||
self.session.removeChannel.assert_not_called()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
import unittest
|
||||
|
||||
import mock
|
||||
|
||||
import koji
|
||||
import kojihub
|
||||
|
||||
UP = kojihub.UpdateProcessor
|
||||
|
||||
|
||||
class TestRemoveChannel(unittest.TestCase):
|
||||
def getUpdate(self, *args, **kwargs):
|
||||
update = UP(*args, **kwargs)
|
||||
update.execute = mock.MagicMock()
|
||||
self.updates.append(update)
|
||||
return update
|
||||
|
||||
def setUp(self):
|
||||
self.UpdateProcessor = mock.patch('kojihub.UpdateProcessor',
|
||||
side_effect=self.getUpdate).start()
|
||||
self.updates = []
|
||||
self.context = mock.patch('kojihub.context').start()
|
||||
self.context.session.assertPerm = mock.MagicMock()
|
||||
self.exports = kojihub.RootExports()
|
||||
self.channel_name = 'test-channel'
|
||||
|
||||
def tearDown(self):
|
||||
mock.patch.stopall()
|
||||
|
||||
@mock.patch('kojihub.get_channel_id')
|
||||
def test_non_exist_channel(self, get_channel_id):
|
||||
get_channel_id.side_effect = koji.GenericError('No such channel: %s' % self.channel_name)
|
||||
|
||||
with self.assertRaises(koji.GenericError):
|
||||
kojihub.remove_channel(self.channel_name)
|
||||
|
||||
get_channel_id.assert_called_once_with(self.channel_name, strict=True)
|
||||
self.assertEqual(len(self.updates), 0)
|
||||
Loading…
Add table
Add a link
Reference in a new issue