[LNT] r332954 - API: add Fields resource.
Martin Liska via llvm-commits
llvm-commits at lists.llvm.org
Tue May 22 00:20:19 PDT 2018
Author: marxin
Date: Tue May 22 00:20:19 2018
New Revision: 332954
URL: http://llvm.org/viewvc/llvm-project?rev=332954&view=rev
Log:
API: add Fields resource.
Differential Revision: https://reviews.llvm.org/D44007
Modified:
lnt/trunk/docs/api.rst
lnt/trunk/lnt/server/ui/api.py
lnt/trunk/tests/server/ui/test_api.py
Modified: lnt/trunk/docs/api.rst
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/docs/api.rst?rev=332954&r1=332953&r2=332954&view=diff
==============================================================================
--- lnt/trunk/docs/api.rst (original)
+++ lnt/trunk/docs/api.rst Tue May 22 00:20:19 2018
@@ -38,6 +38,8 @@ once.
+---------------------------+------------------------------------------------------------------------------------------+
| /schema | Return test suite schema. |
+---------------------------+------------------------------------------------------------------------------------------+
+| /fields | Return all fields in this testsuite. |
++---------------------------+------------------------------------------------------------------------------------------+
.. _auth_tokens:
Modified: lnt/trunk/lnt/server/ui/api.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/ui/api.py?rev=332954&r1=332953&r2=332954&view=diff
==============================================================================
--- lnt/trunk/lnt/server/ui/api.py (original)
+++ lnt/trunk/lnt/server/ui/api.py Tue May 22 00:20:19 2018
@@ -61,6 +61,18 @@ def add_common_fields(to_update):
"""Update a dict with the common fields."""
to_update.update(common_fields_factory())
+class Fields(Resource):
+ """List all the fields in the test suite."""
+ method_decorators = [in_db]
+
+ @staticmethod
+ def get():
+ ts = request.get_testsuite()
+
+ result = common_fields_factory()
+ result['fields'] = [{'column_id': i, 'column_name': f.column.name}
+ for i, f in enumerate(ts.sample_fields)]
+ return result
class Machines(Resource):
"""List all the machines and give summary information."""
@@ -501,6 +513,7 @@ def load_api_resources(api):
resp.headers.extend(headers)
return resp
+ api.add_resource(Fields, ts_path("fields"), ts_path("fields/"))
api.add_resource(Machines, ts_path("machines"), ts_path("machines/"))
api.add_resource(Machine, ts_path("machines/<machine_spec>"))
api.add_resource(Runs, ts_path("runs"), ts_path("runs/"))
Modified: lnt/trunk/tests/server/ui/test_api.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/tests/server/ui/test_api.py?rev=332954&r1=332953&r2=332954&view=diff
==============================================================================
--- lnt/trunk/tests/server/ui/test_api.py (original)
+++ lnt/trunk/tests/server/ui/test_api.py Tue May 22 00:20:19 2018
@@ -242,6 +242,21 @@ class JSONAPITester(unittest.TestCase):
self._check_response_is_well_formed(two_runs)
self.assertEqual(j, two_runs)
+ def test_fields_api(self):
+ """Fields API."""
+ client = self.client
+ j = check_json(client, 'api/db_default/v4/nts/fields')
+
+ fields = j['fields']
+
+ # check number of fields
+ self.assertEqual(9, len(fields))
+
+ # check first field
+ f0 = fields[0]
+ self.assertEqual(0, f0['column_id'])
+ self.assertEqual('compile_status', f0['column_name'])
+
def test_schema(self):
client = self.client
rest_schema = check_json(client, 'api/db_default/v4/nts/schema')
More information about the llvm-commits
mailing list