Index: lnt/trunk/docs/api.rst =================================================================== --- lnt/trunk/docs/api.rst +++ lnt/trunk/docs/api.rst @@ -40,6 +40,8 @@ +---------------------------+------------------------------------------------------------------------------------------+ | /fields | Return all fields in this testsuite. | +---------------------------+------------------------------------------------------------------------------------------+ +| /tests | Return all tests in this testsuite. | ++---------------------------+------------------------------------------------------------------------------------------+ .. _auth_tokens: Index: lnt/trunk/lnt/server/ui/api.py =================================================================== --- lnt/trunk/lnt/server/ui/api.py +++ lnt/trunk/lnt/server/ui/api.py @@ -72,6 +72,21 @@ 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 @@ 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/")) 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 @@ -257,6 +257,21 @@ 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')