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: 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/")) api.add_resource(Runs, ts_path("runs"), ts_path("runs/")) 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')