From 2e947402a47eabc1279395b52630f166d02b54a7 Mon Sep 17 00:00:00 2001 From: hughhhh Date: Tue, 4 Apr 2023 00:13:11 -0400 Subject: [PATCH] fix test --- superset/charts/api.py | 13 ++++--- superset/dashboards/api.py | 34 +++++++++++++------ superset/queries/saved_queries/api.py | 11 +++--- tests/integration_tests/tags/dao_tests.py | 2 +- .../tasks/async_queries_tests.py | 1 - 5 files changed, 40 insertions(+), 21 deletions(-) diff --git a/superset/charts/api.py b/superset/charts/api.py index 7792505af9173..aa6ea5ebe0e35 100644 --- a/superset/charts/api.py +++ b/superset/charts/api.py @@ -145,8 +145,8 @@ def ensure_thumbnails_enabled(self) -> Optional[Response]: "query_context", "is_managed_externally", ] - - show_columns += ["tags.id", "tags.name", "tags.type"] + if is_feature_enabled("TAGGING_SYSTEM"): + show_columns += ["tags.id", "tags.name", "tags.type"] show_select_columns = show_columns + ["table.id"] list_columns = [ @@ -195,7 +195,8 @@ def ensure_thumbnails_enabled(self) -> Optional[Response]: "url", "viz_type", ] - list_columns += ["tags.id", "tags.name", "tags.type"] + if is_feature_enabled("TAGGING_SYSTEM"): + list_columns += ["tags.id", "tags.name", "tags.type"] list_select_columns = list_columns + ["changed_by_fk", "changed_on"] order_columns = [ "changed_by.first_name", @@ -224,7 +225,8 @@ def ensure_thumbnails_enabled(self) -> Optional[Response]: "slice_name", "viz_type", ] - search_columns += ["tags"] + if is_feature_enabled("TAGGING_SYSTEM"): + search_columns += ["tags"] base_order = ("changed_on", "desc") base_filters = [["id", ChartFilter, lambda: []]] search_filters = { @@ -236,7 +238,8 @@ def ensure_thumbnails_enabled(self) -> Optional[Response]: "slice_name": [ChartAllTextFilter], "created_by": [ChartHasCreatedByFilter, ChartCreatedByMeFilter], } - search_filters["tags"] = [ChartTagFilter] + if is_feature_enabled("TAGGING_SYSTEM"): + search_filters["tags"] = [ChartTagFilter] # Will just affect _info endpoint edit_columns = ["slice_name"] diff --git a/superset/dashboards/api.py b/superset/dashboards/api.py index ee2b3549db198..a252cff000118 100644 --- a/superset/dashboards/api.py +++ b/superset/dashboards/api.py @@ -190,7 +190,8 @@ def ensure_thumbnails_enabled(self) -> Optional[Response]: "roles.name", "is_managed_externally", ] - list_columns += ["tags.id", "tags.name", "tags.type"] + if is_feature_enabled("TAGGING_SYSTEM"): + list_columns += ["tags.id", "tags.name", "tags.type"] list_select_columns = list_columns + ["changed_on", "created_on", "changed_by_fk"] order_columns = [ "changed_by.first_name", @@ -216,15 +217,28 @@ def ensure_thumbnails_enabled(self) -> Optional[Response]: edit_columns = add_columns search_columns = ( - "created_by", - "changed_by", - "dashboard_title", - "id", - "owners", - "published", - "roles", - "slug", - "tags", + ( + "created_by", + "changed_by", + "dashboard_title", + "id", + "owners", + "published", + "roles", + "slug", + "tags", + ) + if is_feature_enabled("TAGGING_SYSTEM") + else ( + "created_by", + "changed_by", + "dashboard_title", + "id", + "owners", + "published", + "roles", + "slug", + ) ) search_filters = { "dashboard_title": [DashboardTitleOrSlugFilter], diff --git a/superset/queries/saved_queries/api.py b/superset/queries/saved_queries/api.py index b85d59eed2930..0996ab9b3f875 100644 --- a/superset/queries/saved_queries/api.py +++ b/superset/queries/saved_queries/api.py @@ -26,6 +26,7 @@ from flask_appbuilder.models.sqla.interface import SQLAInterface from flask_babel import ngettext +from superset import is_feature_enabled from superset.commands.importers.exceptions import ( IncorrectFormatError, NoValidFilesFoundError, @@ -118,7 +119,8 @@ class SavedQueryRestApi(BaseSupersetModelRestApi): "sql", "sql_tables", ] - list_columns += ["tags.id", "tags.name", "tags.type"] + if is_feature_enabled("TAGGING_SYSTEM"): + list_columns += ["tags.id", "tags.name", "tags.type"] list_select_columns = list_columns + ["changed_by_fk", "changed_on"] add_columns = [ "db_id", @@ -143,13 +145,14 @@ class SavedQueryRestApi(BaseSupersetModelRestApi): ] search_columns = ["id", "database", "label", "schema", "created_by"] - search_columns += ["tags"] + if is_feature_enabled("TAGGING_SYSTEM"): + search_columns += ["tags"] search_filters = { "id": [SavedQueryFavoriteFilter], "label": [SavedQueryAllTextFilter], } - - search_filters["tags"] = [SavedQueryTagFilter] + if is_feature_enabled("TAGGING_SYSTEM"): + search_filters["tags"] = [SavedQueryTagFilter] apispec_parameter_schemas = { "get_delete_ids_schema": get_delete_ids_schema, diff --git a/tests/integration_tests/tags/dao_tests.py b/tests/integration_tests/tags/dao_tests.py index 97776fb845d24..f46abaa723bda 100644 --- a/tests/integration_tests/tags/dao_tests.py +++ b/tests/integration_tests/tags/dao_tests.py @@ -296,5 +296,5 @@ def test_delete_tagged_object(self): def test_validate_tag_name(self): assert TagDAO.validate_tag_name("example_tag_name") is True assert TagDAO.validate_tag_name("invalid:tag_name") is False - db.session.query(Tag).delete() db.session.query(TaggedObject).delete() + db.session.query(Tag).delete() diff --git a/tests/integration_tests/tasks/async_queries_tests.py b/tests/integration_tests/tasks/async_queries_tests.py index 75f587616773e..9e5c9657cf936 100644 --- a/tests/integration_tests/tasks/async_queries_tests.py +++ b/tests/integration_tests/tasks/async_queries_tests.py @@ -44,7 +44,6 @@ class TestAsyncQueries(SupersetTestCase): @pytest.mark.usefixtures("load_birth_names_dashboard_with_slices") - @pytest.mark.usefixtures("with_tagging_system_feature") @mock.patch.object(async_query_manager, "update_job") @mock.patch.object(async_queries, "set_form_data") def test_load_chart_data_into_cache(self, mock_set_form_data, mock_update_job):