Commit dbd35982 authored by Wei Shoulin's avatar Wei Shoulin
Browse files

feat(catalog): add limit parameter to search function and implement describe_catalog

- Add optional `limit` parameter to the `search` function in catalog.py
- Implement new `describe_catalog` function to get column information of a catalog
- Update unit tests to include the new parameter and test the new function
- Minor formatting improvements in docstrings and test cases
parent 9a8486ac
......@@ -76,3 +76,23 @@ def all_catalog_names() -> Result:
return Result.ok_data(data = records)
except Exception as e:
return Result.error(str(e))
def describe_catalog(catalog_name: str) -> Result:
"""
获取星表各列信息。
Returns:
Result: 列描述的列表。
Raises:
Exception: 如果请求失败,将抛出异常。
"""
try:
datas = request.get(f'/api/catalog/describe/{catalog_name}')
if datas and isinstance(datas, Result):
return datas
records = pickle.loads(datas._content)
return Result.ok_data(data = records)
except Exception as e:
return Result.error(str(e))
......@@ -28,3 +28,9 @@ class CatalogTestCase(unittest.TestCase):
print(result)
self.assertEqual(result.code, 200, "error code: " + str(result.code) + ", message: " + result.message)
self.assertIsNotNone(result.data, "error message: " + result.message)
def test_describe_catalog(self):
result = catalog.describe_catalog('gaia3_source')
print(result)
self.assertEqual(result.code, 200, "error code: " + str(result.code) + ", message: " + result.message)
self.assertIsNotNone(result.data, "error message: " + result.message)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment