Browse Source

REST API: fix discrepancies between RPC and REST outputs for autohold

The REST API implementation of autohold-list and autohold-info was
missing some fields and misnaming others compared to the RPC output.
This fixes problems with the CLI when using autohold-list via the REST
client.

Change-Id: I29748bda8c59888ea521ae65201fc3bacefd3a91
changes/73/728073/6
Matthieu Huin 1 year ago
parent
commit
3572b4cc34
  1. 12
      tests/unit/test_web.py
  2. 14
      zuul/web/__init__.py

12
tests/unit/test_web.py

@ -815,8 +815,10 @@ class TestWeb(BaseTestWeb):
self.assertIn('org/project', request['project'])
self.assertEqual('project-test2', request['job'])
self.assertEqual(".*", request['ref_filter'])
self.assertEqual(1, request['count'])
self.assertEqual(1, request['max_count'])
self.assertEqual(0, request['current_count'])
self.assertEqual("reason text", request['reason'])
self.assertEqual([], request['nodes'])
def test_autohold_list(self):
"""test listing autoholds through zuul-web"""
@ -839,8 +841,10 @@ class TestWeb(BaseTestWeb):
self.assertIn('org/project', ah_request['project'])
self.assertEqual('project-test2', ah_request['job'])
self.assertEqual(".*", ah_request['ref_filter'])
self.assertEqual(1, ah_request['count'])
self.assertEqual(1, ah_request['max_count'])
self.assertEqual(0, ah_request['current_count'])
self.assertEqual("reason text", ah_request['reason'])
self.assertEqual([], ah_request['nodes'])
# filter by project
resp = self.get_url(
@ -861,8 +865,10 @@ class TestWeb(BaseTestWeb):
self.assertIn('org/project', ah_request['project'])
self.assertEqual('project-test2', ah_request['job'])
self.assertEqual(".*", ah_request['ref_filter'])
self.assertEqual(1, ah_request['count'])
self.assertEqual(1, ah_request['max_count'])
self.assertEqual(0, ah_request['current_count'])
self.assertEqual("reason text", ah_request['reason'])
self.assertEqual([], ah_request['nodes'])
def test_admin_routes_404_by_default(self):
resp = self.post_url(

14
zuul/web/__init__.py

@ -453,9 +453,12 @@ class ZuulWebAPI(object):
'project': request['project'],
'job': request['job'],
'ref_filter': request['ref_filter'],
'count': request['max_count'],
'max_count': request['max_count'],
'current_count': request['current_count'],
'reason': request['reason'],
'node_hold_expiration': request['node_expiration']
'node_expiration': request['node_expiration'],
'expired': request['expired'],
'nodes': request['nodes']
})
resp = cherrypy.response
resp.headers['Access-Control-Allow-Origin'] = '*'
@ -490,9 +493,12 @@ class ZuulWebAPI(object):
'project': request['project'],
'job': request['job'],
'ref_filter': request['ref_filter'],
'count': request['max_count'],
'max_count': request['max_count'],
'current_count': request['current_count'],
'reason': request['reason'],
'node_hold_expiration': request['node_expiration']
'node_expiration': request['node_expiration'],
'expired': request['expired'],
'nodes': request['nodes']
}
def _autohold_delete(self, request_id):

Loading…
Cancel
Save