[LNT] r333259 - API: add Tests resource.
Martin Liska via llvm-commits
llvm-commits at lists.llvm.org
Fri May 25 00:56:01 PDT 2018
Author: marxin
Date: Fri May 25 00:56:00 2018
New Revision: 333259
URL: http://llvm.org/viewvc/llvm-project?rev=333259&view=rev
Log:
API: add Tests resource.
Differential Revision: https://reviews.llvm.org/D47185
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=333259&r1=333258&r2=333259&view=diff
==============================================================================
--- lnt/trunk/docs/api.rst (original)
+++ lnt/trunk/docs/api.rst Fri May 25 00:56:00 2018
@@ -40,6 +40,8 @@ once.
+---------------------------+------------------------------------------------------------------------------------------+
| /fields | Return all fields in this testsuite. |
+---------------------------+------------------------------------------------------------------------------------------+
+| /tests | Return all tests 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=333259&r1=333258&r2=333259&view=diff
==============================================================================
--- lnt/trunk/lnt/server/ui/api.py (original)
+++ lnt/trunk/lnt/server/ui/api.py Fri May 25 00:56:00 2018
@@ -72,6 +72,21 @@ class Fields(Resource):
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 Tests(Resource):
+ """List all the tests in the test suite."""
+ method_decorators = [in_db]
+
+ @staticmethod
+ def get():
+ ts = request.get_testsuite()
+
+ result = common_fields_factory()
+ tests = request.session.query(ts.Test).all()
+ result['tests'] = [t.__json__() for t in tests]
+
return result
class Machines(Resource):
@@ -513,6 +528,7 @@ def load_api_resources(api):
resp.headers.extend(headers)
return resp
+ api.add_resource(Tests, ts_path("tests"), ts_path("tests/"))
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>"))
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=333259&r1=333258&r2=333259&view=diff
==============================================================================
--- lnt/trunk/tests/server/ui/test_api.py (original)
+++ lnt/trunk/tests/server/ui/test_api.py Fri May 25 00:56:00 2018
@@ -257,6 +257,21 @@ class JSONAPITester(unittest.TestCase):
self.assertEqual(0, f0['column_id'])
self.assertEqual('compile_status', f0['column_name'])
+ def test_tests_api(self):
+ """Tests API."""
+ client = self.client
+ j = check_json(client, 'api/db_default/v4/nts/tests')
+
+ tests = j['tests']
+
+ # check number of tests
+ self.assertEqual(9, len(tests))
+
+ # check first test
+ t0 = tests[0]
+ self.assertEqual(1, t0['id'])
+ self.assertEqual('SingleSource/UnitTests/2006-12-01-float_varg', t0['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