mirror of
https://github.com/apache/superset.git
synced 2026-04-19 08:04:53 +00:00
feat: Use DuckDB for examples data in Docker development environment (#34831)
Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Beto Dealmeida <roberto@dealmeida.net>
This commit is contained in:
committed by
GitHub
parent
9c9588cce6
commit
47414e18d4
@@ -58,9 +58,14 @@ CSV_FILE_WITH_NULLS = [
|
||||
|
||||
|
||||
def _setup_csv_upload(allowed_schemas: list[str] | None = None):
|
||||
upload_db = get_or_create_db(
|
||||
CSV_UPLOAD_DATABASE, app.config["SQLALCHEMY_EXAMPLES_URI"]
|
||||
)
|
||||
# Use main database URI for schema-related tests (PostgreSQL-specific)
|
||||
# Use examples URI for general upload tests
|
||||
if allowed_schemas:
|
||||
db_uri = app.config["SQLALCHEMY_DATABASE_URI"]
|
||||
else:
|
||||
db_uri = app.config["SQLALCHEMY_EXAMPLES_URI"]
|
||||
|
||||
upload_db = get_or_create_db(CSV_UPLOAD_DATABASE, db_uri)
|
||||
upload_db.allow_file_upload = True
|
||||
extra = upload_db.get_extra()
|
||||
allowed_schemas = allowed_schemas or []
|
||||
|
||||
@@ -37,8 +37,9 @@ class TestDatasourceValidateExpressionApi(SupersetTestCase):
|
||||
# Mock successful validation
|
||||
mock_validate.return_value = {"valid": True, "errors": []}
|
||||
|
||||
# Use a test datasource ID
|
||||
datasource_id = 1
|
||||
# Use the birth_names dataset for testing
|
||||
datasource = self.get_birth_names_dataset()
|
||||
datasource_id = datasource.id
|
||||
|
||||
rv = self.client.post(
|
||||
f"/api/v1/datasource/table/{datasource_id}/validate_expression/",
|
||||
@@ -61,7 +62,9 @@ class TestDatasourceValidateExpressionApi(SupersetTestCase):
|
||||
# Mock successful validation
|
||||
mock_validate.return_value = {"valid": True, "errors": []}
|
||||
|
||||
datasource_id = 1 # Assuming we have a datasource with ID 1
|
||||
# Use the birth_names dataset for testing
|
||||
datasource = self.get_birth_names_dataset()
|
||||
datasource_id = datasource.id
|
||||
|
||||
rv = self.client.post(
|
||||
f"/api/v1/datasource/table/{datasource_id}/validate_expression/",
|
||||
@@ -84,7 +87,9 @@ class TestDatasourceValidateExpressionApi(SupersetTestCase):
|
||||
# Mock successful validation
|
||||
mock_validate.return_value = {"valid": True, "errors": []}
|
||||
|
||||
datasource_id = 1
|
||||
# Use the birth_names dataset for testing
|
||||
datasource = self.get_birth_names_dataset()
|
||||
datasource_id = datasource.id
|
||||
|
||||
rv = self.client.post(
|
||||
f"/api/v1/datasource/table/{datasource_id}/validate_expression/",
|
||||
@@ -107,7 +112,9 @@ class TestDatasourceValidateExpressionApi(SupersetTestCase):
|
||||
# Mock successful validation
|
||||
mock_validate.return_value = {"valid": True, "errors": []}
|
||||
|
||||
datasource_id = 1
|
||||
# Use the birth_names dataset for testing
|
||||
datasource = self.get_birth_names_dataset()
|
||||
datasource_id = datasource.id
|
||||
|
||||
rv = self.client.post(
|
||||
f"/api/v1/datasource/table/{datasource_id}/validate_expression/",
|
||||
@@ -126,7 +133,9 @@ class TestDatasourceValidateExpressionApi(SupersetTestCase):
|
||||
"""Test validation of invalid SQL expression"""
|
||||
self.login("admin")
|
||||
|
||||
datasource_id = 1
|
||||
# Use the birth_names dataset for testing
|
||||
datasource = self.get_birth_names_dataset()
|
||||
datasource_id = datasource.id
|
||||
|
||||
with patch(
|
||||
"superset.connectors.sqla.models.SqlaTable.validate_expression"
|
||||
@@ -154,7 +163,9 @@ class TestDatasourceValidateExpressionApi(SupersetTestCase):
|
||||
"""Test that HAVING clause fails for non-aggregated columns"""
|
||||
self.login("admin")
|
||||
|
||||
datasource_id = 1
|
||||
# Use the birth_names dataset for testing
|
||||
datasource = self.get_birth_names_dataset()
|
||||
datasource_id = datasource.id
|
||||
|
||||
with patch(
|
||||
"superset.connectors.sqla.models.SqlaTable.validate_expression"
|
||||
@@ -189,7 +200,9 @@ class TestDatasourceValidateExpressionApi(SupersetTestCase):
|
||||
"""Test validation of empty expression"""
|
||||
self.login("admin")
|
||||
|
||||
datasource_id = 1
|
||||
# Use the birth_names dataset for testing
|
||||
datasource = self.get_birth_names_dataset()
|
||||
datasource_id = datasource.id
|
||||
|
||||
rv = self.client.post(
|
||||
f"/api/v1/datasource/table/{datasource_id}/validate_expression/",
|
||||
@@ -205,7 +218,9 @@ class TestDatasourceValidateExpressionApi(SupersetTestCase):
|
||||
"""Test validation with missing required parameters"""
|
||||
self.login("admin")
|
||||
|
||||
datasource_id = 1
|
||||
# Use the birth_names dataset for testing
|
||||
datasource = self.get_birth_names_dataset()
|
||||
datasource_id = datasource.id
|
||||
|
||||
# Missing expression_type - defaults to "where"
|
||||
rv = self.client.post(
|
||||
@@ -242,7 +257,9 @@ class TestDatasourceValidateExpressionApi(SupersetTestCase):
|
||||
# Create a user without admin privileges
|
||||
self.login("gamma")
|
||||
|
||||
datasource_id = 1
|
||||
# Use the birth_names dataset for testing
|
||||
datasource = self.get_birth_names_dataset()
|
||||
datasource_id = datasource.id
|
||||
|
||||
rv = self.client.post(
|
||||
f"/api/v1/datasource/table/{datasource_id}/validate_expression/",
|
||||
|
||||
Reference in New Issue
Block a user