From 7f6b4228b15ea9b3991102d9b2daa006b0cd5017 Mon Sep 17 00:00:00 2001 From: Beto Dealmeida Date: Mon, 6 Nov 2023 17:55:48 -0500 Subject: [PATCH] Add test --- superset/db_engine_specs/base.py | 4 ++-- tests/unit_tests/db_engine_specs/test_dremio.py | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/superset/db_engine_specs/base.py b/superset/db_engine_specs/base.py index 542e73739a636..6bce03d931710 100644 --- a/superset/db_engine_specs/base.py +++ b/superset/db_engine_specs/base.py @@ -400,8 +400,8 @@ class BaseEngineSpec: # pylint: disable=too-many-public-methods @classmethod def get_allows_alias_in_select( - cls, database: Database - ) -> bool: # pylint: disable=unused-argument + cls, database: Database # pylint: disable=unused-argument + ) -> bool: """ Method for dynamic `allows_alias_in_select`. diff --git a/tests/unit_tests/db_engine_specs/test_dremio.py b/tests/unit_tests/db_engine_specs/test_dremio.py index 6b1e8203b5dfe..eb77e7f10a292 100644 --- a/tests/unit_tests/db_engine_specs/test_dremio.py +++ b/tests/unit_tests/db_engine_specs/test_dremio.py @@ -18,6 +18,7 @@ from typing import Optional import pytest +from pytest_mock import MockerFixture from tests.unit_tests.db_engine_specs.utils import assert_convert_dttm from tests.unit_tests.fixtures.common import dttm @@ -40,3 +41,18 @@ def test_convert_dttm( from superset.db_engine_specs.dremio import DremioEngineSpec as spec assert_convert_dttm(spec, target_type, expected_result, dttm) + + +def test_get_allows_alias_in_select(mocker: MockerFixture) -> None: + from superset.db_engine_specs.dremio import DremioEngineSpec + + database = mocker.MagicMock() + + database.get_extra.return_value = {} + assert DremioEngineSpec.get_allows_alias_in_select(database) is True + + database.get_extra.return_value = {"version": "24.1.0"} + assert DremioEngineSpec.get_allows_alias_in_select(database) is True + + database.get_extra.return_value = {"version": "24.0.0"} + assert DremioEngineSpec.get_allows_alias_in_select(database) is False