#3000 Add all types to docs latest-build and readTaggedBuilds
Merged 8 months ago by tkopecek. Opened 9 months ago by jcupova.
jcupova/koji issue-2953  into  master

file modified
+2 -1
@@ -2529,7 +2529,8 @@ 

      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"))

file modified
+1 -1
@@ -1283,7 +1283,7 @@ 

      :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

@@ -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()

Could you put this once into class variable? It is a lot of lines repeating.

Can you move usage string to class variable in the tests? It is a lot of lines just repeating that message.

rebased onto 8fcbba9

9 months ago

pretty please pagure-ci rebuild

9 months ago

Metadata Update from @tkopecek:
- Pull-request tagged with: testing-ready

9 months ago

Metadata Update from @mfilip:
- Pull-request tagged with: testing-done

8 months ago

Commit b41e547 fixes this pull-request

Pull-Request has been merged by tkopecek

8 months ago