[PATCH] D44007: [LNT] API: add Fields resource.
Martin Liška via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue May 22 00:24:34 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL332954: API: add Fields resource. (authored by marxin, committed by ).
Herald added a subscriber: llvm-commits.
Changed prior to commit:
https://reviews.llvm.org/D44007?vs=146544&id=147955#toc
Repository:
rL LLVM
https://reviews.llvm.org/D44007
Files:
lnt/trunk/docs/api.rst
lnt/trunk/lnt/server/ui/api.py
lnt/trunk/tests/server/ui/test_api.py
Index: lnt/trunk/tests/server/ui/test_api.py
===================================================================
--- lnt/trunk/tests/server/ui/test_api.py
+++ lnt/trunk/tests/server/ui/test_api.py
@@ -242,6 +242,21 @@
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')
Index: lnt/trunk/lnt/server/ui/api.py
===================================================================
--- lnt/trunk/lnt/server/ui/api.py
+++ lnt/trunk/lnt/server/ui/api.py
@@ -61,6 +61,18 @@
"""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 @@
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/"))
Index: lnt/trunk/docs/api.rst
===================================================================
--- lnt/trunk/docs/api.rst
+++ lnt/trunk/docs/api.rst
@@ -38,6 +38,8 @@
+---------------------------+------------------------------------------------------------------------------------------+
| /schema | Return test suite schema. |
+---------------------------+------------------------------------------------------------------------------------------+
+| /fields | Return all fields in this testsuite. |
++---------------------------+------------------------------------------------------------------------------------------+
.. _auth_tokens:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44007.147955.patch
Type: text/x-patch
Size: 2805 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180522/37e5d88e/attachment.bin>
More information about the llvm-commits
mailing list