Browse Source

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

changes/83/703983/7
Zuul 3 months ago
committed by Gerrit Code Review
parent
commit
5d0fbb5ac8
2 changed files with 19 additions and 7 deletions
  1. +9
    -3
      tests/unit/test_web.py
  2. +10
    -4
      zuul/web/__init__.py

+ 9
- 3
tests/unit/test_web.py View File

@@ -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(


+ 10
- 4
zuul/web/__init__.py View File

@@ -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