#3769 Add component/built archives in list-buildroot
Merged a year ago by tkopecek. Opened a year ago by jcupova.
jcupova/koji issue-3759  into  master

file modified
+22 -3
@@ -2785,7 +2785,7 @@ 

      "[info] List the rpms used in or built in a buildroot"

      usage = "usage: %prog list-buildroot [options] <buildroot-id>"

      parser = OptionParser(usage=get_usage_str(usage))

-     parser.add_option("--built", action="store_true", help="Show the built rpms")

+     parser.add_option("--built", action="store_true", help="Show the built rpms and archives")

      parser.add_option("--verbose", "-v", action="store_true", help="Show more information")

      (options, args) = parser.parse_args(args)

      if len(args) != 1:
@@ -2797,16 +2797,35 @@ 

          opts['buildrootID'] = buildrootID

      else:

          opts['componentBuildrootID'] = buildrootID

-     data = session.listRPMs(**opts)

+ 

+     list_rpms = session.listRPMs(**opts)

+     if list_rpms:

+         if options.built:

+             print('Built RPMs:')

+         else:

+             print('Component RPMs:')

  

      fmt = "%(nvr)s.%(arch)s"

-     order = sorted([(fmt % x, x) for x in data])

+     order = sorted([(fmt % x, x) for x in list_rpms])

      for nvra, rinfo in order:

          if options.verbose and rinfo.get('is_update'):

              print("%s [update]" % nvra)

          else:

              print(nvra)

  

+     list_archives = session.listArchives(**opts)

+     if list_archives:

+         if list_rpms:

+             # print empty line between list of RPMs and archives

+             print('')

+         if options.built:

+             print('Built Archives:')

+         else:

+             print('Component Archives:')

+     order = sorted([x['filename'] for x in list_archives])

+     for filename in order:

+         print(filename)

+ 

  

  def anon_handle_list_untagged(goptions, session, args):

      "[info] List untagged builds"

@@ -33,8 +33,9 @@ 

          self.session.listRPMs.assert_not_called()

  

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

-     def test_list_buildroot_with_verbose(self, stdout):

-         expected_output = """testpackage-1.1-7.f33.noarch

+     def test_list_buildroot_with_verbose_with_rpms_without_archives(self, stdout):

+         expected_output = """Component RPMs:

+ testpackage-1.1-7.f33.noarch

  testpkg-1.171-5.fc33.noarch [update]

  tpkg-4.11-1.fc33.x86_64 [update]

  """
@@ -42,15 +43,60 @@ 

                       {'arch': 'noarch', 'is_update': False, 'nvr': 'testpackage-1.1-7.f33'},

                       {'arch': 'x86_64', 'is_update': True, 'nvr': 'tpkg-4.11-1.fc33'}]

          self.session.listRPMs.return_value = list_rpms

+         self.session.listArchives.return_value = []

          rv = anon_handle_list_buildroot(self.options, self.session, ['--verbose', '1'])

          self.assertEqual(rv, None)

          self.assert_console_message(stdout, expected_output)

          self.ensure_connection_mock.assert_called_once_with(self.session, self.options)

          self.session.listRPMs.assert_called_once_with(componentBuildrootID=1)

+         self.session.listArchives.assert_called_once_with(componentBuildrootID=1)

  

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

-     def test_list_buildroot_with_built(self, stdout):

-         expected_output = """testpackage-1.1-7.f33.x86_64

+     def test_list_buildroot_with_verbose_without_rpms_with_archives(self, stdout):

+         expected_output = """Component Archives:

+ archivename1.tar.gz

+ archivename2.zip

+ """

+         list_archives = [{'filename': 'archivename2.zip'},

+                          {'filename': 'archivename1.tar.gz'}]

+         self.session.listRPMs.return_value = []

+         self.session.listArchives.return_value = list_archives

+         rv = anon_handle_list_buildroot(self.options, self.session, ['--verbose', '1'])

+         self.assertEqual(rv, None)

+         self.assert_console_message(stdout, expected_output)

+         self.ensure_connection_mock.assert_called_once_with(self.session, self.options)

+         self.session.listRPMs.assert_called_once_with(componentBuildrootID=1)

+         self.session.listArchives.assert_called_once_with(componentBuildrootID=1)

+ 

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

+     def test_list_buildroot_with_verbose_with_rpms_with_archives(self, stdout):

+         expected_output = """Component RPMs:

+ testpackage-1.1-7.f33.noarch

+ testpkg-1.171-5.fc33.noarch [update]

+ tpkg-4.11-1.fc33.x86_64 [update]

+ 

+ Component Archives:

+ archivename1.tar.gz

+ archivename2.zip

+ """

+         list_rpms = [{'arch': 'noarch', 'is_update': True, 'nvr': 'testpkg-1.171-5.fc33'},

+                      {'arch': 'noarch', 'is_update': False, 'nvr': 'testpackage-1.1-7.f33'},

+                      {'arch': 'x86_64', 'is_update': True, 'nvr': 'tpkg-4.11-1.fc33'}]

+         list_archives = [{'filename': 'archivename2.zip'},

+                          {'filename': 'archivename1.tar.gz'}]

+         self.session.listRPMs.return_value = list_rpms

+         self.session.listArchives.return_value = list_archives

+         rv = anon_handle_list_buildroot(self.options, self.session, ['--verbose', '1'])

+         self.assertEqual(rv, None)

+         self.assert_console_message(stdout, expected_output)

+         self.ensure_connection_mock.assert_called_once_with(self.session, self.options)

+         self.session.listRPMs.assert_called_once_with(componentBuildrootID=1)

+         self.session.listArchives.assert_called_once_with(componentBuildrootID=1)

+ 

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

+     def test_list_buildroot_with_built_with_rpms_without_archives(self, stdout):

+         expected_output = """Built RPMs:

+ testpackage-1.1-7.f33.x86_64

  testpkg-1.171-5.fc33.noarch

  tpkg-4.11-1.fc33.noarch

  """
@@ -58,11 +104,30 @@ 

                       {'arch': 'x86_64', 'nvr': 'testpackage-1.1-7.f33'},

                       {'arch': 'noarch', 'nvr': 'tpkg-4.11-1.fc33'}]

          self.session.listRPMs.return_value = list_rpms

+         self.session.listArchives.return_value = []

+         rv = anon_handle_list_buildroot(self.options, self.session, ['--built', '2'])

+         self.assertEqual(rv, None)

+         self.assert_console_message(stdout, expected_output)

+         self.ensure_connection_mock.assert_called_once_with(self.session, self.options)

+         self.session.listRPMs.assert_called_once_with(buildrootID=2)

+         self.session.listArchives.assert_called_once_with(buildrootID=2)

+ 

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

+     def test_list_buildroot_with_built_without_rpms_with_archives(self, stdout):

+         expected_output = """Built Archives:

+ archivename1.tar.gz

+ archivename2.zip

+ """

+         list_archives = [{'filename': 'archivename2.zip'},

+                          {'filename': 'archivename1.tar.gz'}]

+         self.session.listRPMs.return_value = []

+         self.session.listArchives.return_value = list_archives

          rv = anon_handle_list_buildroot(self.options, self.session, ['--built', '2'])

          self.assertEqual(rv, None)

          self.assert_console_message(stdout, expected_output)

          self.ensure_connection_mock.assert_called_once_with(self.session, self.options)

          self.session.listRPMs.assert_called_once_with(buildrootID=2)

+         self.session.listArchives.assert_called_once_with(buildrootID=2)

  

      def test_list_buildroot_help(self):

          self.assert_help(
@@ -72,7 +137,7 @@ 

  

  Options:

    -h, --help     show this help message and exit

-   --built        Show the built rpms

+   --built        Show the built rpms and archives

    -v, --verbose  Show more information

  """ % self.progname)

          self.ensure_connection_mock.assert_not_called()

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

a year ago

rebased onto a437d9d

a year ago

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

a year ago

Commit 14dcab5 fixes this pull-request

Pull-Request has been merged by tkopecek

a year ago