Skip to content

Commit 2aa5805

Browse files
author
Jesse Whitehouse
committed
Add e2e test using inspector
Signed-off-by: Jesse Whitehouse <[email protected]>
1 parent 78a5ad0 commit 2aa5805

File tree

3 files changed

+45
-5
lines changed

3 files changed

+45
-5
lines changed

src/databricks/sqlalchemy/requirements.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def table_reflection(self):
163163
def comment_reflection(self):
164164
"""Indicates if the database support table comment reflection"""
165165
return sqlalchemy.testing.exclusions.open()
166-
166+
167167
@property
168168
def comment_reflection_full_unicode(self):
169169
"""Indicates if the database support table comment reflection in the

src/databricks/sqlalchemy/test/_future.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,6 @@ def test_get_multi_check_constraints(self):
271271
pass
272272

273273

274-
275-
276274
class ComponentReflectionTestExtra(ComponentReflectionTestExtra):
277275
@pytest.mark.skip(render_future_feature(FutureFeature.CHECK))
278276
def test_get_check_constraints(self):

src/databricks/sqlalchemy/test_local/e2e/test_basic.py

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import datetime
22
import decimal
33
import os
4-
from typing import Tuple, Union
4+
from typing import Tuple, Union, List
55
from unittest import skipIf
66

77
import pytest
@@ -477,7 +477,7 @@ def sample_table(metadata_obj: MetaData, db_engine: Engine):
477477

478478
table_name = "PySQLTest_{}".format(datetime.datetime.utcnow().strftime("%s"))
479479

480-
args = [
480+
args: List[Column] = [
481481
Column(colname, coltype) for colname, coltype in GET_COLUMNS_TYPE_MAP.items()
482482
]
483483

@@ -499,3 +499,45 @@ def test_get_columns(db_engine, sample_table: str):
499499
columns = inspector.get_columns(sample_table)
500500

501501
assert True
502+
503+
504+
class TestCommentReflection:
505+
@pytest.fixture(scope="class")
506+
def engine(self):
507+
HOST = os.environ.get("host")
508+
HTTP_PATH = os.environ.get("http_path")
509+
ACCESS_TOKEN = os.environ.get("access_token")
510+
CATALOG = os.environ.get("catalog")
511+
SCHEMA = os.environ.get("schema")
512+
513+
connection_string = f"databricks://token:{ACCESS_TOKEN}@{HOST}?http_path={HTTP_PATH}&catalog={CATALOG}&schema={SCHEMA}"
514+
connect_args = {"_user_agent_entry": USER_AGENT_TOKEN}
515+
516+
engine = create_engine(connection_string, connect_args=connect_args)
517+
return engine
518+
519+
@pytest.fixture
520+
def inspector(self, engine: Engine) -> Inspector:
521+
return Inspector.from_engine(engine)
522+
523+
@pytest.fixture
524+
def table(self, engine):
525+
md = MetaData()
526+
tbl = Table(
527+
"foo",
528+
md,
529+
Column("bar", String, comment="column comment"),
530+
comment="table comment",
531+
)
532+
md.create_all(bind=engine)
533+
534+
yield tbl
535+
536+
md.drop_all(bind=engine)
537+
538+
def test_table_comment_reflection(self, inspector: Inspector, table: Table):
539+
tbl_name = table.name
540+
541+
comment = inspector.get_table_comment(tbl_name)
542+
543+
assert comment == {"text": "table comment"}

0 commit comments

Comments
 (0)