fix unit tests
This commit is contained in:
parent
0b935caf85
commit
48b8deef6e
3 changed files with 13 additions and 6 deletions
|
|
@ -34,6 +34,7 @@ class TestHostinfo(utils.CliTestCase):
|
|||
'comment': 'test-comment',
|
||||
'description': 'test-description'}
|
||||
self.last_update = 1615875554.862938
|
||||
self.last_update_str = '2021-03-16 06:19:14.862938-00:00'
|
||||
self.list_channels = [{'id': 1, 'name': 'default'}, {'id': 2, 'name': 'createrepo'}]
|
||||
self.error_format = """Usage: %s hostinfo [options] <hostname> [<hostname> ...]
|
||||
(Specify the --help global option for a list of other help options)
|
||||
|
|
@ -142,6 +143,7 @@ None
|
|||
|
||||
@mock.patch('sys.stdout', new_callable=StringIO)
|
||||
def test_hostinfo_valid_param_error(self, stdout):
|
||||
'''Test the fallback code for getting timestamps from old hubs'''
|
||||
expected = """Name: kojibuilder
|
||||
ID: 1
|
||||
Arches: x86_64
|
||||
|
|
@ -157,7 +159,8 @@ Active Buildroots:
|
|||
None
|
||||
"""
|
||||
self.session.getHost.return_value = self.hostinfo
|
||||
self.session.getLastHostUpdate.side_effect = [koji.ParameterError, self.last_update]
|
||||
# simulate an older hub that doesn't support the ts option for getLastHostUpdate
|
||||
self.session.getLastHostUpdate.side_effect = [koji.ParameterError, self.last_update_str]
|
||||
self.session.listChannels.return_value = self.list_channels
|
||||
rv = anon_handle_hostinfo(self.options, self.session, [self.hostinfo['name']])
|
||||
self.assertEqual(rv, None)
|
||||
|
|
|
|||
|
|
@ -179,10 +179,12 @@ kojibuilder N Y 0.0/2.0 x86_64 Tue, 16 Mar 2021 06:19:14 UTC
|
|||
|
||||
@mock.patch('sys.stdout', new_callable=StringIO)
|
||||
def test_list_hosts_param_error_get_last_host_update(self, stdout):
|
||||
host_update = 1615875554.862938
|
||||
# host_update = 1615875554.862938
|
||||
host_update = '2021-03-16 06:19:14.862938-00:00'
|
||||
expected = "kojibuilder N Y 0.0/2.0 x86_64 " \
|
||||
"Tue, 16 Mar 2021 06:19:14 UTC \n"
|
||||
|
||||
# simulate an older hub that doesn't support the ts option for getLastHostUpdate
|
||||
self.session.getLastHostUpdate.side_effect = [koji.ParameterError, host_update]
|
||||
self.session.multiCall.return_value = [[host_update]]
|
||||
self.session.listHosts.return_value = self.list_hosts
|
||||
|
|
|
|||
|
|
@ -33,12 +33,13 @@ class TestSetHostEnabled(unittest.TestCase):
|
|||
|
||||
self.assertEqual(len(self.queries), 1)
|
||||
query = self.queries[0]
|
||||
columns = ['host.id', 'host.user_id', 'host.name', 'host.ready',
|
||||
columns = ['host.id', 'host.user_id', 'host.name',
|
||||
"date_part('epoch', host.update_time)", 'host.ready',
|
||||
'host.task_load', 'host_config.arches',
|
||||
'host_config.capacity', 'host_config.description',
|
||||
'host_config.comment', 'host_config.enabled']
|
||||
joins = ['host ON host.id = host_config.host_id']
|
||||
aliases = ['id', 'user_id', 'name', 'ready', 'task_load',
|
||||
aliases = ['id', 'user_id', 'name', 'update_ts', 'ready', 'task_load',
|
||||
'arches', 'capacity', 'description', 'comment', 'enabled']
|
||||
clauses = ['(host_config.active = TRUE)', '(host.name = %(host_name)s)']
|
||||
values = {'host_name': 'hostname'}
|
||||
|
|
@ -54,12 +55,13 @@ class TestSetHostEnabled(unittest.TestCase):
|
|||
|
||||
self.assertEqual(len(self.queries), 1)
|
||||
query = self.queries[0]
|
||||
columns = ['host.id', 'host.user_id', 'host.name', 'host.ready',
|
||||
columns = ['host.id', 'host.user_id', 'host.name',
|
||||
"date_part('epoch', host.update_time)", 'host.ready',
|
||||
'host.task_load', 'host_config.arches',
|
||||
'host_config.capacity', 'host_config.description',
|
||||
'host_config.comment', 'host_config.enabled']
|
||||
joins = ['host ON host.id = host_config.host_id']
|
||||
aliases = ['id', 'user_id', 'name', 'ready', 'task_load',
|
||||
aliases = ['id', 'user_id', 'name', 'update_ts', 'ready', 'task_load',
|
||||
'arches', 'capacity', 'description', 'comment', 'enabled']
|
||||
clauses = ['(host_config.create_event <= 345 AND ( host_config.revoke_event IS NULL '
|
||||
'OR 345 < host_config.revoke_event ))',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue