Merge "Convert max-skipped parameter to int"

This commit is contained in:
Zuul
2021-12-13 15:20:08 +00:00
committed by Gerrit Code Review
2 changed files with 21 additions and 1 deletions

View File

@@ -348,7 +348,7 @@ def get_last_job_results(zuul_url, insecure, max_skipped, last_uuid):
"""Yield builds until we find the last uuid."""
count = 0
for build in get_builds(zuul_url, insecure):
if count > max_skipped:
if count > int(max_skipped):
break
if build["uuid"] == last_uuid:
break

View File

@@ -154,6 +154,26 @@ class TestScraper(base.TestCase):
self.assertRaises(ValueError, logscraper.check_connection,
args.logstash_url)
@mock.patch('logscraper.logscraper.get_builds',
return_value=iter([{'uuid': '1234'}]))
def test_get_last_job_results(self, mock_get_builds):
job_result = logscraper.get_last_job_results(
'http://somehost.com/api/tenant/tenant1', False, '1234',
'someuuid')
self.assertEqual([{'uuid': '1234'}], list(job_result))
self.assertEqual(1, mock_get_builds.call_count)
@mock.patch('logscraper.logscraper.get_builds',
return_value=iter([{'uuid': '1234'}]))
def test_get_last_job_results_wrong_max_skipped(self, mock_get_builds):
def make_fake_list(x):
return list(x)
job_result = logscraper.get_last_job_results(
'http://somehost.com/api/tenant/tenant1', False, 'somevalue',
'someuuid')
self.assertRaises(ValueError, make_fake_list, job_result)
@mock.patch('multiprocessing.pool.Pool.map')
@mock.patch('builtins.open', new_callable=mock.mock_open())
@mock.patch('os.path.isfile')