mirror of
https://github.com/apache/superset.git
synced 2026-04-17 07:05:04 +00:00
feat: add separate endpoint to fetch function names for autocomplete (#12840)
* WIP * Add unit test for API * Add spec * Fix unit test * Fix unit test * Fix test * Fix test * Add period to error message
This commit is contained in:
@@ -137,7 +137,6 @@ class TestDatabaseApi(SupersetTestCase):
|
||||
"explore_database_id",
|
||||
"expose_in_sqllab",
|
||||
"force_ctas_schema",
|
||||
"function_names",
|
||||
"id",
|
||||
]
|
||||
self.assertGreater(response["count"], 0)
|
||||
@@ -589,7 +588,8 @@ class TestDatabaseApi(SupersetTestCase):
|
||||
assert rv.status_code == 200
|
||||
assert "can_read" in data["permissions"]
|
||||
assert "can_write" in data["permissions"]
|
||||
assert len(data["permissions"]) == 2
|
||||
assert "can_function_names" in data["permissions"]
|
||||
assert len(data["permissions"]) == 3
|
||||
|
||||
def test_get_invalid_database_table_metadata(self):
|
||||
"""
|
||||
@@ -1125,3 +1125,20 @@ class TestDatabaseApi(SupersetTestCase):
|
||||
|
||||
db.session.delete(database)
|
||||
db.session.commit()
|
||||
|
||||
@mock.patch("superset.db_engine_specs.base.BaseEngineSpec.get_function_names",)
|
||||
def test_function_names(self, mock_get_function_names):
|
||||
example_db = get_example_database()
|
||||
if example_db.backend in {"hive", "presto"}:
|
||||
return
|
||||
|
||||
mock_get_function_names.return_value = ["AVG", "MAX", "SUM"]
|
||||
|
||||
self.login(username="admin")
|
||||
uri = "api/v1/database/1/function_names/"
|
||||
|
||||
rv = self.client.get(uri)
|
||||
response = json.loads(rv.data.decode("utf-8"))
|
||||
|
||||
assert rv.status_code == 200
|
||||
assert response == {"function_names": ["AVG", "MAX", "SUM"]}
|
||||
|
||||
Reference in New Issue
Block a user