From 3c84d99bf4a6158719638e33591f1d74215f20e9 Mon Sep 17 00:00:00 2001 From: Jana Cupova Date: May 11 2022 07:56:48 +0000 Subject: Add header separaton to list-hosts and list-channels Fixes: https://pagure.io/koji/issue/3337 --- diff --git a/cli/koji_cli/commands.py b/cli/koji_cli/commands.py index 0c7c618..4c08506 100644 --- a/cli/koji_cli/commands.py +++ b/cli/koji_cli/commands.py @@ -3059,7 +3059,9 @@ def anon_handle_list_channels(goptions, session, args): longest_channel = 8 if options.simple: if not options.quiet: - print('Channel') + hdr = 'Channel' + print(hdr) + print(len(hdr) * '-') for channel in channels: print(channel['name']) else: @@ -3072,6 +3074,7 @@ def anon_handle_list_channels(goptions, session, args): if options.comment and 'comment' in first_item: hdr += "Comment".ljust(53) print(hdr) + print(len(hdr) * '-') mask = "%%(name)-%ss %%(enabled_host)6d %%(ready)6d %%(disabled)6d %%(load)6d %%(" \ "capacity)6d %%(perc_load)6d%%%%" % longest_channel if options.description and 'description' in first_item: @@ -3185,6 +3188,7 @@ def anon_handle_list_hosts(goptions, session, args): if options.show_channels: hdr += "Channels" print(hdr) + print(len(hdr) * '-') mask = "%%(name)-%ss %%(enabled)-3s %%(ready)-3s %%(task_load)4.1f/%%(capacity)-4.1f " \ "%%(arches)-16s %%(update)-35s" % longest_host if options.description: diff --git a/tests/test_cli/test_list_channels.py b/tests/test_cli/test_list_channels.py index 0dee915..1ac30fc 100644 --- a/tests/test_cli/test_list_channels.py +++ b/tests/test_cli/test_list_channels.py @@ -56,6 +56,7 @@ class TestListChannels(utils.CliTestCase): actual = stdout.getvalue() expected = "Channel Enabled Ready Disbld Load Cap Perc \n" \ + "-------------------------------------------------------------\n" \ "default 3 1 0 1 6 22%\n" \ "test [disabled] 2 2 1 1 6 28%\n" @@ -105,6 +106,9 @@ class TestListChannels(utils.CliTestCase): expected = "Channel Enabled Ready Disbld Load Cap Perc " \ "Description " \ "Comment \n" \ + "---------------------------------------------------------------------------" \ + "---------------------------------------------------------------------------" \ + "-----------------\n" \ "default 3 1 0 1 6 22% " \ "test-description-1 " \ "test-comment-1 \n" \ @@ -199,6 +203,7 @@ class TestListChannels(utils.CliTestCase): actual = stdout.getvalue() expected = """Channel +------- default test [disabled] """ diff --git a/tests/test_cli/test_list_hosts.py b/tests/test_cli/test_list_hosts.py index 93f691c..f9d1955 100644 --- a/tests/test_cli/test_list_hosts.py +++ b/tests/test_cli/test_list_hosts.py @@ -52,6 +52,7 @@ class TestListHosts(utils.CliTestCase): self.options.quiet = False host_update = 1615875554.862938 expected = """Hostname Enb Rdy Load/Cap Arches Last Update +----------------------------------------------------------------------------------- kojibuilder N Y 0.0/2.0 x86_64 Tue, 16 Mar 2021 06:19:14 UTC """ @@ -190,6 +191,9 @@ kojibuilder N Y 0.0/2.0 x86_64 Tue, 16 Mar 2021 06:19:14 UTC expected = "Hostname Enb Rdy Load/Cap Arches Last Update" \ " Description " \ "Comment \n" \ + "---------------------------------------------------------------------------" \ + "---------------------------------------------------------------------------" \ + "-----------------------------------\n" \ "kojibuilder N Y 0.0/2.0 x86_64 Tue, 16 Mar 2021 06:19:14 UTC" \ " test-description test-comment" \ " \n"