CLI list-untagged: One space only instead of double space before references
Fixes: https://pagure.io/koji/issue/3730
This commit is contained in:
parent
c0d537c4f0
commit
175c618e5b
2 changed files with 50 additions and 9 deletions
|
|
@ -2854,7 +2854,7 @@ def anon_handle_list_untagged(goptions, session, args):
|
||||||
else:
|
else:
|
||||||
fmt = "%(name)s-%(version)s-%(release)s"
|
fmt = "%(name)s-%(version)s-%(release)s"
|
||||||
if options.show_references:
|
if options.show_references:
|
||||||
fmt = fmt + " %(refs)s"
|
fmt = fmt + " %(refs)s"
|
||||||
output = sorted([fmt % x for x in data])
|
output = sorted([fmt % x for x in data])
|
||||||
for line in output:
|
for line in output:
|
||||||
print(line)
|
print(line)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
import koji
|
||||||
import mock
|
import mock
|
||||||
import unittest
|
import unittest
|
||||||
from six.moves import StringIO
|
from six.moves import StringIO
|
||||||
|
|
@ -9,17 +10,29 @@ from . import utils
|
||||||
|
|
||||||
class TestListUntagged(utils.CliTestCase):
|
class TestListUntagged(utils.CliTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
self.maxDiff = None
|
||||||
self.session = mock.MagicMock()
|
self.session = mock.MagicMock()
|
||||||
self.options = mock.MagicMock()
|
self.options = mock.MagicMock()
|
||||||
self.untagged_values = [{'id': 1,
|
self.untagged_values = [{'id': 1,
|
||||||
'name': 'test-package-1234',
|
'name': 'test-package-1234',
|
||||||
'release': '11',
|
'release': '11',
|
||||||
'version': '1.1'},
|
'version': '1.1'},
|
||||||
{'id': 2,
|
{'id': 2,
|
||||||
'name': 'test-package-1234',
|
'name': 'test-package-1234',
|
||||||
'release': '99',
|
'release': '99',
|
||||||
'version': '1.33'}
|
'version': '1.33'}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
def __vm(self, result):
|
||||||
|
m = koji.VirtualCall('mcall_method', [], {})
|
||||||
|
if isinstance(result, dict) and result.get('faultCode'):
|
||||||
|
m._result = result
|
||||||
|
else:
|
||||||
|
m._result = (result,)
|
||||||
|
return m
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
mock.patch.stopall()
|
||||||
|
|
||||||
@mock.patch('sys.stdout', new_callable=StringIO)
|
@mock.patch('sys.stdout', new_callable=StringIO)
|
||||||
@mock.patch('koji_cli.commands.ensure_connection')
|
@mock.patch('koji_cli.commands.ensure_connection')
|
||||||
|
|
@ -89,6 +102,34 @@ class TestListUntagged(utils.CliTestCase):
|
||||||
['--paths', package_name])
|
['--paths', package_name])
|
||||||
self.assert_console_message(stdout, expected)
|
self.assert_console_message(stdout, expected)
|
||||||
|
|
||||||
|
@mock.patch('sys.stdout', new_callable=StringIO)
|
||||||
|
@mock.patch('koji_cli.commands.ensure_connection')
|
||||||
|
def test_list_untagged_package_show_references(self, ensure_connection, stdout):
|
||||||
|
# test case when package is existing
|
||||||
|
rpms = [{'rpm_id': 123}, {'rpm_id': 125}]
|
||||||
|
archives = [{'archive_id': 999}, {'archive_id': 888}]
|
||||||
|
components = [{'archive_id': 999, 'rpm_id': 125}]
|
||||||
|
build_references = {'tags': [{'name': 'tag-48rj15ma3a', 'tag_id': 2}],
|
||||||
|
'rpms': rpms,
|
||||||
|
'component_of': components,
|
||||||
|
'archives': archives,
|
||||||
|
'last_used': None,
|
||||||
|
'images': []}
|
||||||
|
mcall = self.session.multicall.return_value.__enter__.return_value
|
||||||
|
mcall.buildReferences.return_value = self.__vm(build_references)
|
||||||
|
package_name = 'test-package-1234'
|
||||||
|
|
||||||
|
self.session.untaggedBuilds.return_value = self.untagged_values
|
||||||
|
list_untagged = [u['name'] + '-' + u['version'] + '-' + u['release']
|
||||||
|
for u in self.untagged_values]
|
||||||
|
expected = """(Showing build references)
|
||||||
|
%s rpms: %s, images/archives: %s, archives buildroots: %s
|
||||||
|
%s rpms: %s, images/archives: %s, archives buildroots: %s
|
||||||
|
""" % (list_untagged[0], rpms, components, archives, list_untagged[1], rpms, components, archives)
|
||||||
|
anon_handle_list_untagged(self.options, self.session,
|
||||||
|
['--show-references', package_name])
|
||||||
|
self.assert_console_message(stdout, expected)
|
||||||
|
|
||||||
def test_handle_list_history_help(self):
|
def test_handle_list_history_help(self):
|
||||||
self.assert_help(
|
self.assert_help(
|
||||||
anon_handle_list_untagged,
|
anon_handle_list_untagged,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue