PR#3000: Add all types to docs latest-build and readTaggedBuilds

Merges #3000
https://pagure.io/koji/pull-request/3000

Fixes: #2953
https://pagure.io/koji/issue/2953
update cli and API docs for build types
This commit is contained in:
Tomas Kopecek 2021-09-08 17:17:36 +02:00
commit b41e5473a5
3 changed files with 102 additions and 2 deletions

View file

@ -2550,7 +2550,8 @@ def anon_handle_latest_build(goptions, session, args):
parser.add_option("--paths", action="store_true", help=_("Show the file paths"))
parser.add_option("--type",
help=_("Show builds of the given type only. "
"Currently supported types: maven"))
"Currently supported types: maven, win, image, or any custom "
"content generator btypes"))
(options, args) = parser.parse_args(args)
if len(args) == 0:
parser.error(_("A tag name must be specified"))

View file

@ -1283,7 +1283,7 @@ def readTaggedBuilds(tag, event=None, inherit=False, latest=False, package=None,
:param int package: filter on package name
:param str owner: filter on user name
:param str type: restrict the list to builds of the given type. Currently the supported
types are 'maven', 'win', and 'image'.
types are 'maven', 'win', 'image', or any custom content generator btypes.
:returns [dict]: list of buildinfo dicts
"""
# build - id pkg_id version release epoch

View file

@ -0,0 +1,99 @@
from __future__ import absolute_import
import unittest
import mock
import six
from koji_cli.commands import anon_handle_latest_build
from . import utils
class TestLatestBuild(utils.CliTestCase):
def setUp(self):
self.maxDiff = None
self.options = mock.MagicMock()
self.session = mock.MagicMock()
self.tag_name = 'test-tag'
self.pkg_name = 'test-pkg'
self.expected_part_help = """Usage: %s latest-build [options] <tag> <package> [<package> ...]
The first option should be the name of a tag, not the name of a build target.
If you want to know the latest build in buildroots for a given build target,
then you should use the name of the build tag for that target. You can find
this value by running '%s list-targets --name=<target>'
More information on tags and build targets can be found in the documentation.
https://docs.pagure.org/koji/HOWTO/#package-organization
(Specify the --help global option for a list of other help options)
""" \
% (self.progname, self.progname)
def tearDown(self):
mock.patch.stopall()
@mock.patch('sys.stderr', new_callable=six.StringIO)
@mock.patch('koji_cli.commands.ensure_connection')
@mock.patch('koji_cli.commands.activate_session')
def test_handle_latest_build_without_args(self, activate_session_mock,
ensure_connection, stderr):
with self.assertRaises(SystemExit) as ex:
anon_handle_latest_build(self.options, self.session, [])
self.assertExitCode(ex, 2)
actual = stderr.getvalue()
expected_stderr = \
self.expected_part_help + "%s: error: A tag name must be specified\n" % self.progname
self.assertMultiLineEqual(actual, expected_stderr)
activate_session_mock.assert_not_called()
ensure_connection.assert_not_called()
@mock.patch('sys.stderr', new_callable=six.StringIO)
@mock.patch('koji_cli.commands.ensure_connection')
@mock.patch('koji_cli.commands.activate_session')
def test_handle_latest_build_more_args(self, activate_session_mock, ensure_connection, stderr):
with self.assertRaises(SystemExit) as ex:
anon_handle_latest_build(self.options, self.session, [self.tag_name])
self.assertExitCode(ex, 2)
actual = stderr.getvalue()
expected_stderr = \
self.expected_part_help + "%s: error: A tag name and package name must " \
"be specified\n" % self.progname
self.assertMultiLineEqual(actual, expected_stderr)
activate_session_mock.assert_not_called()
ensure_connection.called_once()
@mock.patch('sys.stderr', new_callable=six.StringIO)
@mock.patch('koji_cli.commands.ensure_connection')
@mock.patch('koji_cli.commands.activate_session')
def test_handle_latest_build_all_and_pkg(self, activate_session_mock, ensure_connection,
stderr):
with self.assertRaises(SystemExit) as ex:
anon_handle_latest_build(self.options, self.session,
['--all', self.tag_name, self.pkg_name])
self.assertExitCode(ex, 2)
actual = stderr.getvalue()
expected_stderr = \
self.expected_part_help + "%s: error: A package name may not be combined " \
"with --all\n" % self.progname
self.assertMultiLineEqual(actual, expected_stderr)
activate_session_mock.assert_not_called()
ensure_connection.called_once()
def test_handle_latest_build_help(self):
self.assert_help(
anon_handle_latest_build,
self.expected_part_help + """Options:
-h, --help show this help message and exit
--arch=ARCH List all of the latest packages for this arch
--all List all of the latest packages for this tag
--quiet Do not print the header information
--paths Show the file paths
--type=TYPE Show builds of the given type only. Currently supported types:
maven, win, image, or any custom content generator btypes
""")
if __name__ == '__main__':
unittest.main()