Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarrmondragon committed Aug 13, 2024
1 parent 92d5156 commit 54c985f
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions tests/core/test_connector_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
import pytest
import sqlalchemy as sa
from sqlalchemy.dialects import registry, sqlite
from sqlalchemy.engine.default import DefaultDialect

from samples.sample_duckdb import DuckDBConnector
from singer_sdk.connectors import SQLConnector
from singer_sdk.connectors.sql import FullyQualifiedName
from singer_sdk.exceptions import ConfigValidationError

if t.TYPE_CHECKING:
Expand Down Expand Up @@ -355,3 +357,35 @@ def create_engine(self) -> Engine:

connector = CustomConnector(config={"sqlalchemy_url": "myrdbms:///"})
connector.create_engine()


def test_fully_qualified_name():
dialect = DefaultDialect()

fqn = FullyQualifiedName(table="my_table", dialect=dialect)
assert fqn == "my_table"

fqn = FullyQualifiedName(schema="my_schema", table="my_table", dialect=dialect)
assert fqn == "my_schema.my_table"

fqn = FullyQualifiedName(
database="my_catalog",
schema="my_schema",
table="my_table",
dialect=dialect,
)
assert fqn == "my_catalog.my_schema.my_table"


def test_fully_qualified_name_with_quoting():
dialect = DefaultDialect()

fqn = FullyQualifiedName(table="order", schema="public", dialect=dialect)
assert fqn == 'public."order"'


def test_fully_qualified_name_empty_error():
dialect = DefaultDialect()

with pytest.raises(ValueError, match="Could not generate fully qualified name"):
FullyQualifiedName(dialect=dialect)

0 comments on commit 54c985f

Please sign in to comment.