jason810496 commented on code in PR #53217:
URL: https://github.com/apache/airflow/pull/53217#discussion_r2203707363
##########
providers/databricks/tests/unit/databricks/hooks/test_databricks_sql.py:
##########
@@ -107,6 +112,41 @@ def mock_timer():
yield mock_timer
+def make_mock_connection():
+ return Connection(
+ conn_id=DEFAULT_CONN_ID,
+ conn_type="databricks",
+ host=HOST,
+ port=PORT,
+ login="token",
+ password=TOKEN,
+ )
+
+
+def test_sqlachemy_url_property(mock_get_conn):
+ mock_get_conn.return_value = make_mock_connection()
+ hook = DatabricksSqlHook(
+ databricks_conn_id=DEFAULT_CONN_ID, http_path=HTTP_PATH,
catalog=CATALOG, schema=SCHEMA
+ )
+ url = hook.sqlalchemy_url.render_as_string(hide_password=False)
+ assert url.startswith(f"databricks://token:{TOKEN}@{HOST}:{PORT}")
+ assert f"http_path={quote_plus(HTTP_PATH)}" in url
+ assert f"catalog={CATALOG}" in url
+ assert f"schema={SCHEMA}" in url
Review Comment:
How about asserting the exact url instead of checking the sub-string in the
url.
##########
providers/databricks/tests/unit/databricks/hooks/test_databricks_sql.py:
##########
@@ -107,6 +112,41 @@ def mock_timer():
yield mock_timer
+def make_mock_connection():
+ return Connection(
+ conn_id=DEFAULT_CONN_ID,
+ conn_type="databricks",
+ host=HOST,
+ port=PORT,
+ login="token",
+ password=TOKEN,
+ )
+
+
+def test_sqlachemy_url_property(mock_get_conn):
+ mock_get_conn.return_value = make_mock_connection()
+ hook = DatabricksSqlHook(
+ databricks_conn_id=DEFAULT_CONN_ID, http_path=HTTP_PATH,
catalog=CATALOG, schema=SCHEMA
+ )
+ url = hook.sqlalchemy_url.render_as_string(hide_password=False)
+ assert url.startswith(f"databricks://token:{TOKEN}@{HOST}:{PORT}")
+ assert f"http_path={quote_plus(HTTP_PATH)}" in url
+ assert f"catalog={CATALOG}" in url
+ assert f"schema={SCHEMA}" in url
+
+
+def test_get_uri(mock_get_conn):
+ mock_get_conn.return_value = make_mock_connection()
+ hook = DatabricksSqlHook(
+ databricks_conn_id=DEFAULT_CONN_ID, http_path=HTTP_PATH,
catalog=CATALOG, schema=SCHEMA
+ )
+ uri = hook.get_uri()
+ assert uri.startswith(f"databricks://token:{TOKEN}@{HOST}:{PORT}")
+ assert f"http_path={quote_plus(HTTP_PATH)}" in uri
+ assert f"catalog={CATALOG}" in uri
+ assert f"schema={SCHEMA}" in uri
Review Comment:
Same here.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]