#2792 cli: mock-config check arch
Merged a year ago by tkopecek. Opened a year ago by jcupova.
jcupova/koji issue2640  into  master

@@ -1023,6 +1023,11 @@ 

      if opts['repoid'] != 'latest':

          event = session.repoInfo(opts['repoid'])['create_event']

      buildcfg = session.getBuildConfig(opts['tag_name'], event=event)

+     if options.arch:

+         if not buildcfg['arches']:

+             warn("Tag %s has an empty arch list" % opts['tag_name'])

+         elif arch not in buildcfg['arches']:

+             warn('%s is not in the list of tag arches' % arch)

      if 'mock.package_manager' in buildcfg['extra']:

          opts['package_manager'] = buildcfg['extra']['mock.package_manager']

      if 'mock.yum.module_hotfixes' in buildcfg['extra']:

@@ -15,6 +15,7 @@ 

      maxDiff = None

  

      def setUp(self):

+         self.maxDiff = None

          self.common_args = [

              '--distribution', 'fedora',

              '--topdir', '/top-dir',
@@ -237,7 +238,8 @@ 

                  'rpm.macro.random_macro2': 'random_macro_content2',

                  'mock.package_manager': 'yum',

                  'mock.yum.module_hotfixes': 1,

-             }

+             },

+             'arches': 'x86_64',

          }

          expected = "Could not get a repo for tag: %(name)s\n" % tag

          with self.assertRaises(SystemExit) as ex:
@@ -273,6 +275,36 @@ 

          gen_config_mock.assert_called_with(

              self.progname, tag['arch'], **opts)

  

+         # return arch warning and config

+         arch = 'test'

+         warn_msg = '%s is not in the list of tag arches' % arch

+         gen_config_mock.return_value = self.mock_output

+         arguments = self.common_args + ['--tag', tag['name'], '--arch', arch,

+                                         '--name', self.progname, '--latest']

+         anon_handle_mock_config(options, session, arguments)

+         self.assert_console_message(stdout, "%s\n" % gen_config_mock.return_value)

+         self.assert_console_message(stderr, "%s\n" % warn_msg)

+ 

+         # return warning that tag arch is empty

+         session.getBuildConfig.return_value = {

+             'id': 301,

+             'extra': {

+                 'rpm.macro.random_macro1': 'random_macro_content1',

+                 'rpm.macro.random_macro2': 'random_macro_content2',

+                 'mock.package_manager': 'yum',

+                 'mock.yum.module_hotfixes': 1,

+             },

+             'arches': None,

+         }

+         arch = 'test'

+         warn_msg = 'Tag %s has an empty arch list' % tag['name']

+         gen_config_mock.return_value = self.mock_output

+         arguments = self.common_args + ['--tag', tag['name'], '--arch', arch,

+                                         '--name', self.progname, '--latest']

+         anon_handle_mock_config(options, session, arguments)

+         self.assert_console_message(stdout, "%s\n" % gen_config_mock.return_value)

+         self.assert_console_message(stderr, "%s\n" % warn_msg)

+ 

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

      @mock.patch('sys.stdout', new_callable=six.StringIO)

      @mock.patch('koji.genMockConfig')
@@ -315,6 +347,7 @@ 

              activate_session=None)

  

          session.getBuildTarget.return_value = target

+         session.getBuildConfig.return_value = {'arches': 'x86_64', 'extra': {}}

          expected = "Could not get a repo for tag: %s\n" % target['build_tag_name']

          with self.assertRaises(SystemExit) as ex:

              anon_handle_mock_config(options, session, arguments)
@@ -349,6 +382,17 @@ 

          gen_config_mock.assert_called_with(

              self.progname, arch, **opts)

  

+         # return arch warning and config

+         arch = 'test'

+         arguments = self.common_args + ['--target', target['name'],

+                                         '--arch', arch,

+                                         '--name', self.progname]

+         warn_msg = '%s is not in the list of tag arches' % arch

+         gen_config_mock.return_value = self.mock_output

+         anon_handle_mock_config(options, session, arguments)

+         self.assert_console_message(stdout, "%s\n" % gen_config_mock.return_value)

+         self.assert_console_message(stderr, "%s\n" % warn_msg)

+ 

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

      @mock.patch('koji_cli.commands.ensure_connection')

      def test_handle_mock_config_errors(self, ensure_connection_mock, stderr):

All these tests should happen in final part of command (on buildcfg). Otherwise you'll call getBuildConfig more times than needed. It should raise different warning if there are no archs in the tag than if arch is not in that list. It would be confusing otherwise.

rebased onto 7d58284b4e860c591a4baa1524fb14a02cdde0e4

a year ago

rebased onto 694d7ef8df5459892b41ccef0a790da49c6285ac

a year ago

rebased onto fd53b5581cf1ad9a1c6e76b03725f6a919b9f13a

a year ago

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

a year ago

rebased onto 8d43582

a year ago

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

a year ago

Commit 7665ea8 fixes this pull-request

Pull-Request has been merged by tkopecek

a year ago