Unify error messages
Unify error messages for CLI Unify error messages for hub Fixes: https://pagure.io/koji/issue/2720
This commit is contained in:
parent
bbe5b4c703
commit
e784373000
77 changed files with 2170 additions and 348 deletions
37
tests/test_cli/test_remove_target.py
Normal file
37
tests/test_cli/test_remove_target.py
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
import mock
|
||||
from six.moves import StringIO
|
||||
|
||||
import koji
|
||||
from koji_cli.commands import handle_remove_target
|
||||
from . import utils
|
||||
|
||||
|
||||
class TestRemoveTarget(utils.CliTestCase):
|
||||
def setUp(self):
|
||||
self.options = mock.MagicMock()
|
||||
self.options.debug = False
|
||||
self.session = mock.MagicMock()
|
||||
self.session.getAPIVersion.return_value = koji.API_VERSION
|
||||
|
||||
@mock.patch('sys.stderr', new_callable=StringIO)
|
||||
def test_remove_target_without_option(self, stderr):
|
||||
expected = "Usage: %s remove-target [options] <name>\n" \
|
||||
"(Specify the --help global option for a list of other help options)\n\n" \
|
||||
"%s: error: Please specify a build target to " \
|
||||
"remove\n" % (self.progname, self.progname)
|
||||
with self.assertRaises(SystemExit) as ex:
|
||||
handle_remove_target(self.options, self.session, [])
|
||||
self.assertExitCode(ex, 2)
|
||||
self.assert_console_message(stderr, expected)
|
||||
|
||||
@mock.patch('sys.stderr', new_callable=StringIO)
|
||||
def test_remove_target_non_exist_target(self, stderr):
|
||||
target = 'test-target'
|
||||
expected = "No such build target: %s\n" % target
|
||||
self.session.getBuildTarget.return_value = None
|
||||
with self.assertRaises(SystemExit) as ex:
|
||||
handle_remove_target(self.options, self.session, [target])
|
||||
self.assertExitCode(ex, 1)
|
||||
self.assert_console_message(stderr, expected)
|
||||
Loading…
Add table
Add a link
Reference in a new issue