mirror of
https://github.com/apache/superset.git
synced 2026-04-18 23:55:00 +00:00
chore(db_engine_specs): clean up column spec logic and add tests (#22871)
This commit is contained in:
@@ -16,7 +16,13 @@
|
||||
# under the License.
|
||||
# pylint: disable=unused-argument, import-outside-toplevel, protected-access
|
||||
|
||||
from pytest import raises
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
|
||||
import pytest
|
||||
|
||||
from tests.unit_tests.db_engine_specs.utils import assert_convert_dttm
|
||||
from tests.unit_tests.fixtures.common import dttm
|
||||
|
||||
|
||||
def test_odbc_impersonation() -> None:
|
||||
@@ -82,5 +88,21 @@ def test_invalid_impersonation() -> None:
|
||||
url = URL("drill+foobar")
|
||||
username = "DoAsUser"
|
||||
|
||||
with raises(SupersetDBAPIProgrammingError):
|
||||
with pytest.raises(SupersetDBAPIProgrammingError):
|
||||
DrillEngineSpec.get_url_for_impersonation(url, True, username)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"target_type,expected_result",
|
||||
[
|
||||
("Date", "TO_DATE('2019-01-02', 'yyyy-MM-dd')"),
|
||||
("TimeStamp", "TO_TIMESTAMP('2019-01-02 03:04:05', 'yyyy-MM-dd HH:mm:ss')"),
|
||||
("UnknownType", None),
|
||||
],
|
||||
)
|
||||
def test_convert_dttm(
|
||||
target_type: str, expected_result: Optional[str], dttm: datetime
|
||||
) -> None:
|
||||
from superset.db_engine_specs.drill import DrillEngineSpec as spec
|
||||
|
||||
assert_convert_dttm(spec, target_type, expected_result, dttm)
|
||||
|
||||
Reference in New Issue
Block a user