Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
villebro committed Aug 15, 2023
1 parent 7376203 commit 114e867
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion superset/connectors/sqla/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ class SqlaTable(
is_sqllab_view = Column(Boolean, default=False)
template_params = Column(Text)
extra = Column(Text)
normalize_columns = Column(Boolean)
normalize_columns = Column(Boolean, default=False)

baselink = "tablemodelview"

Expand Down
1 change: 1 addition & 0 deletions superset/datasets/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ def fix_extra(self, data: dict[str, Any], **kwargs: Any) -> dict[str, Any]:
data = fields.URL()
is_managed_externally = fields.Boolean(allow_none=True, dump_default=False)
external_url = fields.String(allow_none=True)
normalize_columns = fields.Boolean(load_default=False)


class GetOrCreateDatasetSchema(Schema):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class SqlaTable(Base):
__tablename__ = "tables"

id = sa.Column(sa.Integer, primary_key=True)
normalize_columns = sa.Column(sa.Boolean)
normalize_columns = sa.Column(sa.Boolean())


def upgrade():
Expand All @@ -50,7 +50,8 @@ def upgrade():
sa.Column(
"normalize_columns",
sa.Boolean(),
nullable=False,
nullable=True,
default=False,
server_default=sa.false(),
),
)
Expand Down
2 changes: 2 additions & 0 deletions superset/views/datasource/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ def save(self) -> FlaskResponse:
return json_error_response(_("Request missing data field."), status=500)

datasource_dict = json.loads(data)
normalize_columns = datasource_dict.get("normalize_columns", False)
datasource_dict["normalize_columns"] = normalize_columns
datasource_id = datasource_dict.get("id")
datasource_type = datasource_dict.get("type")
database_id = datasource_dict["database"].get("id")
Expand Down
4 changes: 1 addition & 3 deletions tests/integration_tests/core_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,9 @@
from superset.connectors.sqla.models import SqlaTable
from superset.db_engine_specs.base import BaseEngineSpec
from superset.db_engine_specs.mssql import MssqlEngineSpec
from superset.exceptions import QueryObjectValidationError, SupersetException
from superset.exceptions import SupersetException
from superset.extensions import async_query_manager, cache_manager
from superset.models import core as models
from superset.models.annotations import Annotation, AnnotationLayer
from superset.models.cache import CacheKey
from superset.models.dashboard import Dashboard
from superset.models.slice import Slice
Expand All @@ -56,7 +55,6 @@
from superset.utils import core as utils
from superset.utils.core import backend
from superset.utils.database import get_example_database
from superset.views import core as views
from superset.views.database.views import DatabaseView
from tests.integration_tests.conftest import CTAS_SCHEMA_NAME, with_feature_flags
from tests.integration_tests.fixtures.birth_names_dashboard import (
Expand Down
1 change: 1 addition & 0 deletions tests/integration_tests/datasets/commands_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ def test_export_dataset_command_key_order(self, mock_g):
"filter_select_enabled",
"fetch_values_predicate",
"extra",
"normalize_columns",
"uuid",
"metrics",
"columns",
Expand Down
3 changes: 2 additions & 1 deletion tests/integration_tests/fixtures/importexport.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@
"sql": None,
"table_name": "birth_names_2",
"template_params": None,
"normalize_columns": False,
}
}
],
Expand Down Expand Up @@ -494,6 +495,7 @@
"sql": "",
"params": None,
"template_params": {},
"normalize_columns": False,
"filter_select_enabled": True,
"fetch_values_predicate": None,
"extra": '{ "certification": { "certified_by": "Data Platform Team", "details": "This table is the source of truth." }, "warning_markdown": "This is a warning." }',
Expand Down Expand Up @@ -523,7 +525,6 @@
"python_date_format": None,
},
],
"normalize_columns": False,
"version": "1.0.0",
"uuid": "10808100-158b-42c4-842e-f32b99d88dfb",
"database_uuid": "b8a1ccd3-779d-4ab7-8ad8-9ab119d7fe89",
Expand Down
5 changes: 4 additions & 1 deletion tests/integration_tests/import_export_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,10 @@ def create_dashboard(self, title, id=0, slcs=[]):
def create_table(self, name, schema=None, id=0, cols_names=[], metric_names=[]):
params = {"remote_id": id, "database_name": "examples"}
table = SqlaTable(
id=id, schema=schema, table_name=name, params=json.dumps(params)
id=id,
schema=schema,
table_name=name,
params=json.dumps(params),
)
for col_name in cols_names:
table.columns.append(TableColumn(column_name=col_name))
Expand Down

0 comments on commit 114e867

Please sign in to comment.