You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ru...@apache.org on 2023/12/12 21:34:57 UTC
(superset) branch master updated: chore(tests): Add tests to the column denormalization flow (#26220)
This is an automated email from the ASF dual-hosted git repository.
rusackas pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/master by this push:
new 3a6fe9f105 chore(tests): Add tests to the column denormalization flow (#26220)
3a6fe9f105 is described below
commit 3a6fe9f105241a7ae87fc02a78cced0c7798d0b0
Author: Vitor Avila <96...@users.noreply.github.com>
AuthorDate: Tue Dec 12 18:34:50 2023 -0300
chore(tests): Add tests to the column denormalization flow (#26220)
---
tests/integration_tests/datasource/api_tests.py | 46 ++++++++++++++++++++++++-
1 file changed, 45 insertions(+), 1 deletion(-)
diff --git a/tests/integration_tests/datasource/api_tests.py b/tests/integration_tests/datasource/api_tests.py
index b6a6af105d..6f37186963 100644
--- a/tests/integration_tests/datasource/api_tests.py
+++ b/tests/integration_tests/datasource/api_tests.py
@@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.
import json
-from unittest.mock import Mock, patch
+from unittest.mock import ANY, Mock, patch
import pytest
@@ -135,3 +135,47 @@ class TestDatasourceApi(SupersetTestCase):
response["message"],
"Unable to get column values for datasource type: sl_table",
)
+
+ @pytest.mark.usefixtures("app_context", "virtual_dataset")
+ @patch("superset.models.helpers.ExploreMixin.values_for_column")
+ def test_get_column_values_normalize_columns_enabled(self, values_for_column_mock):
+ self.login(username="admin")
+ table = self.get_virtual_dataset()
+ table.normalize_columns = True
+ rv = self.client.get(f"api/v1/datasource/table/{table.id}/column/col2/values/")
+ values_for_column_mock.assert_called_with(
+ column_name="col2",
+ limit=10000,
+ denormalize_column=False,
+ )
+
+ @pytest.mark.usefixtures("app_context", "virtual_dataset")
+ @patch("superset.db_engine_specs.base.BaseEngineSpec.denormalize_name")
+ def test_get_column_values_not_denormalize_column(self, denormalize_name_mock):
+ self.login(username="admin")
+ table = self.get_virtual_dataset()
+ table.normalize_columns = True
+ rv = self.client.get(f"api/v1/datasource/table/{table.id}/column/col2/values/")
+ denormalize_name_mock.assert_not_called()
+
+ @pytest.mark.usefixtures("app_context", "virtual_dataset")
+ @patch("superset.models.helpers.ExploreMixin.values_for_column")
+ def test_get_column_values_normalize_columns_disabled(self, values_for_column_mock):
+ self.login(username="admin")
+ table = self.get_virtual_dataset()
+ table.normalize_columns = False
+ rv = self.client.get(f"api/v1/datasource/table/{table.id}/column/col2/values/")
+ values_for_column_mock.assert_called_with(
+ column_name="col2",
+ limit=10000,
+ denormalize_column=True,
+ )
+
+ @pytest.mark.usefixtures("app_context", "virtual_dataset")
+ @patch("superset.db_engine_specs.base.BaseEngineSpec.denormalize_name")
+ def test_get_column_values_denormalize_column(self, denormalize_name_mock):
+ self.login(username="admin")
+ table = self.get_virtual_dataset()
+ table.normalize_columns = False
+ rv = self.client.get(f"api/v1/datasource/table/{table.id}/column/col2/values/")
+ denormalize_name_mock.assert_called_with(ANY, "col2")