feat(DB engine spec): get_catalog_names (#23447)

This commit is contained in:
Beto Dealmeida
2023-03-22 13:40:14 -07:00
committed by GitHub
parent fb270cbbd5
commit 8588f81855
3 changed files with 62 additions and 0 deletions

View File

@@ -17,6 +17,7 @@
from textwrap import dedent
from unittest import mock
from flask.ctx import AppContext
from sqlalchemy import column, literal_column
from sqlalchemy.dialects import postgresql
@@ -24,6 +25,7 @@ from superset.db_engine_specs import load_engine_specs
from superset.db_engine_specs.postgres import PostgresEngineSpec
from superset.errors import ErrorLevel, SupersetError, SupersetErrorType
from superset.models.sql_lab import Query
from superset.utils.database import get_example_database
from tests.integration_tests.db_engine_specs.base_tests import TestDbEngineSpec
from tests.integration_tests.fixtures.certificates import ssl_certificate
from tests.integration_tests.fixtures.database import default_db_extra
@@ -514,3 +516,19 @@ def test_base_parameters_mixin():
},
"required": ["database", "host", "port", "username"],
}
def test_get_catalog_names(app_context: AppContext) -> None:
"""
Test the ``get_catalog_names`` method.
"""
database = get_example_database()
if database.backend != "postgresql":
return
with database.get_inspector_with_context() as inspector:
assert PostgresEngineSpec.get_catalog_names(database, inspector) == [
"postgres",
"superset",
]