Merge "Reporting docker deployment improvement"
[releng.git] / utils / test / reporting / api / handlers / testcases.py
1 ##############################################################################
2 # Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
3 #
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
9 import requests
10
11 from tornado.escape import json_encode
12
13 from api.handlers import BaseHandler
14 from api import conf
15
16
17 class TestCases(BaseHandler):
18     def get(self, project):
19         self._set_header()
20
21         url = '{}/projects/{}/cases'.format(conf.base_url, project)
22         cases = requests.get(url).json().get('testcases', [])
23         data = [{t['name']: t['catalog_description']} for t in cases]
24         self.write(json_encode(data))
25
26
27 class TestCase(BaseHandler):
28     def get(self, project, name):
29         self._set_header()
30
31         url = '{}/projects/{}/cases/{}'.format(conf.base_url, project, name)
32         data = requests.get(url).json()
33         self.write(json_encode(data))