#940 Add --enabled --ready filters for list-channels
Merged 5 years ago by mikem. Opened 5 years ago by tkopecek.
tkopecek/koji issue939  into  master

file modified
+6 -4
@@ -2712,12 +2712,14 @@ 

      session.multicall = True

      for channel in channels:

          session.listHosts(channelID=channel['id'])

-     for channel, hosts in zip(channels, session.multiCall()):

-         channel['hosts'] = len(hosts[0])

+     for channel, [hosts] in zip(channels, session.multiCall()):

+         channel['enabled'] = len([x for x in hosts if x['enabled']])

+         channel['disabled'] = len(hosts) - channel['enabled']

+         channel['ready'] = len([x for x in hosts if x['ready']])

      if not options.quiet:

-         print('Channel         Hosts')

+         print('Channel           Enb   Rdy   Dis')

      for channel in channels:

-         print("%(name)-15s %(hosts) 5d" % channel)

+         print("%(name)-15s %(enabled)5d %(ready)5d %(disabled)5d" % channel)

  

  

  def anon_handle_list_hosts(goptions, session, args):

@@ -22,11 +22,22 @@ 

              {'id': 1, 'name': 'default'},

              {'id': 2, 'name': 'test'},

          ]

-         self.session.multiCall.return_value = [[[1,2,3]], [[4,5]]]

+         self.session.multiCall.return_value = [

+             [[

+                 {'enabled': True, 'ready': True},

+                 {'enabled': True, 'ready': False},

+                 {'enabled': True, 'ready': False},

+             ]],

+             [[

+                 {'enabled': True, 'ready': True},

+                 {'enabled': False, 'ready': True},

+                 {'enabled': True, 'ready': False},

+             ]],

+         ]

  

          anon_handle_list_channels(self.options, self.session, self.args)

  

          actual = stdout.getvalue()

-         expected = 'default             3\ntest                2\n'

+         expected = 'default             3     1     0\ntest                2     2     1\n'

          self.assertMultiLineEqual(actual, expected)

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

1 new commit added

  • display more info
5 years ago

rebased onto 990a78f

5 years ago

Looks good, but needs a unit test update

Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/mock/mock.py", line 1305, in patched
    return func(*args, **keywargs)
  File "/home/mike/Devel/koji/koji/tests/test_cli/test_list_channels.py", line 27, in test_list_channels
    anon_handle_list_channels(self.options, self.session, self.args)
  File "/home/mike/Devel/koji/koji/cli/koji_cli/commands.py", line 2716, in anon_handle_list_channels
    channel['enabled'] = len([x for x in hosts if x['enabled']])
TypeError: 'int' object has no attribute '__getitem__'

1 new commit added

  • fix test
5 years ago

Test fixed, btw, jenkins is behaving randomly these days, so most tests are not run :-(

Commit f3b4af0 fixes this pull-request

Pull-Request has been merged by mikem

5 years ago