#3546 Increase list-tag-inheritance unit tests
Merged a year ago by tkopecek. Opened a year ago by jcupova.
jcupova/koji issue-3545  into  master

@@ -1,7 +1,6 @@ 

  from __future__ import absolute_import

  

  import mock

- from six.moves import StringIO

  

  import koji

  from koji_cli.commands import anon_handle_list_tag_inheritance
@@ -10,51 +9,74 @@ 

  

  class TestListTagInheritance(utils.CliTestCase):

      def setUp(self):

+         self.maxDiff = None

          self.options = mock.MagicMock()

          self.options.debug = False

          self.session = mock.MagicMock()

          self.session.getAPIVersion.return_value = koji.API_VERSION

          self.tag = 'test-tag'

+         self.error_format = """Usage: %s list-tag-inheritance [options] <tag>

  

-     @mock.patch('sys.stderr', new_callable=StringIO)

-     def test_without_option(self, stderr):

-         expected = "Usage: %s list-tag-inheritance [options] <tag>\n\n" \

-                    "Prints tag inheritance with basic information about links.\n" \

-                    "Four flags could be seen in the output:\n" \

-                    " M - maxdepth - limits inheritance to n-levels\n" \

-                    " F - package filter (packages ignored for inheritance)\n" \

-                    " I - intransitive link - inheritance immediately stops here\n" \

-                    " N - noconfig - if tag is used in buildroot, its configuration values " \

-                    "will not be used\n\n" \

-                    "Exact values for maxdepth and package filter can be inquired by " \

-                    "taginfo command.\n\n" \

-                    "(Specify the --help global option for a list of other help options)\n\n" \

-                    "%s: error: This command takes exactly one argument: " \

-                    "a tag name or ID\n" % (self.progname, self.progname)

-         with self.assertRaises(SystemExit) as ex:

-             anon_handle_list_tag_inheritance(self.options, self.session, [])

-         self.assertExitCode(ex, 2)

-         self.assert_console_message(stderr, expected)

- 

-     @mock.patch('sys.stderr', new_callable=StringIO)

-     def test_with_non_exist_tag(self, stderr):

-         expected = "Usage: %s list-tag-inheritance [options] <tag>\n\n" \

-                    "Prints tag inheritance with basic information about links.\n" \

-                    "Four flags could be seen in the output:\n" \

-                    " M - maxdepth - limits inheritance to n-levels\n" \

-                    " F - package filter (packages ignored for inheritance)\n" \

-                    " I - intransitive link - inheritance immediately stops here\n" \

-                    " N - noconfig - if tag is used in buildroot, its configuration values " \

-                    "will not be used\n\n" \

-                    "Exact values for maxdepth and package filter can be inquired by " \

-                    "taginfo command.\n\n" \

-                    "(Specify the --help global option for a list of other help options)\n\n" \

-                    "%s: error: No such tag: %s\n" % (self.progname, self.progname, self.tag)

+ Prints tag inheritance with basic information about links.

+ Four flags could be seen in the output:

+  M - maxdepth - limits inheritance to n-levels

+  F - package filter (packages ignored for inheritance)

+  I - intransitive link - inheritance immediately stops here

+  N - noconfig - if tag is used in buildroot, its configuration values will not be used

+ 

+ Exact values for maxdepth and package filter can be inquired by taginfo command.

+ 

+ (Specify the --help global option for a list of other help options)

+ 

+ %s: error: {message}

+ """ % (self.progname, self.progname)

+ 

+     def test_without_option(self):

+         expected_msg = self.format_error_message("This command takes exactly one argument: "

+                                                  "a tag name or ID")

+         self.assert_system_exit(

+             anon_handle_list_tag_inheritance,

+             self.options, self.session, [],

+             stderr=expected_msg,

+             stdout='',

+             activate_session=None,

+             exit_code=2)

+ 

+     def test_with_non_exist_tag(self):

+         expected_msg = self.format_error_message("No such tag: %s" % self.tag)

+         self.session.getTag.return_value = None

+         self.assert_system_exit(

+             anon_handle_list_tag_inheritance,

+             self.options, self.session, [self.tag],

+             stderr=expected_msg,

+             stdout='',

+             activate_session=None,

+             exit_code=2)

+         self.session.getTag.assert_called_once_with(self.tag)

+ 

+     def test_removed_stop_option(self):

+         expected_msg = self.format_error_message("--stop option has been removed in 1.26")

          self.session.getTag.return_value = None

-         with self.assertRaises(SystemExit) as ex:

-             anon_handle_list_tag_inheritance(self.options, self.session, [self.tag])

-         self.assertExitCode(ex, 2)

-         self.assert_console_message(stderr, expected)

+         self.assert_system_exit(

+             anon_handle_list_tag_inheritance,

+             self.options, self.session, ['--stop=test', self.tag],

+             stderr=expected_msg,

+             stdout='',

+             activate_session=None,

+             exit_code=2)

+         self.session.getTag.assert_not_called()

+ 

+     def test_removed_jump_option(self):

+         expected_msg = self.format_error_message("--jump option has been removed in 1.26")

+         self.session.getTag.return_value = None

+         self.assert_system_exit(

+             anon_handle_list_tag_inheritance,

+             self.options, self.session, ['--jump=test', self.tag],

+             stderr=expected_msg,

+             stdout='',

+             activate_session=None,

+             exit_code=2)

+         self.session.getTag.assert_not_called()

  

      def test_help(self):

          self.assert_help(

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

a year ago

rebased onto c8aab83

a year ago

Metadata Update from @jcupova:
- Pull-request untagged with: testing-ready
- Pull-request tagged with: no_qe

a year ago

Commit 59df6e9 fixes this pull-request

Pull-Request has been merged by tkopecek

a year ago