zuul-web: jobs list endpoint: Add test and fix tenant not found 500 error

Job lists test was missing so this add a minimal one and
also fix the 500 errors return when the tenant does not
exist.

Change-Id: Ifa161a0c6ac801ced0d55dd48d1d5f83833aeea4
This commit is contained in:
Fabien Boucher
2018-07-12 17:04:01 +02:00
parent 19afda37a3
commit 0ecccbc349
3 changed files with 11 additions and 0 deletions

View File

@@ -269,6 +269,8 @@ class ZuulWebAPI(object):
def jobs(self, tenant):
job = self.rpc.submitJob('zuul:job_list', {'tenant': tenant})
ret = json.loads(job.data[0])
if ret is None:
raise cherrypy.HTTPError(404, 'Tenant %s does not exist.' % tenant)
resp = cherrypy.response
resp.headers['Access-Control-Allow-Origin'] = '*'
return ret