Taragolis commented on code in PR #34603:
URL: https://github.com/apache/airflow/pull/34603#discussion_r1336003279
##########
tests/providers/apache/druid/hooks/test_druid.py:
##########
@@ -213,6 +214,36 @@ def test_get_auth_with_no_user_and_password(self,
mock_get_connection):
mock_get_connection.return_value = get_conn_value
assert self.db_hook.get_auth() is None
+class TestDruidDbApiHookConn:
+ def setup_method(self):
+ self.connection = Connection(
+ host="test_host",
+ port=10000,
+ login="test_login",
+ password="test_password",
+ extra='{"endpoint": "/test/endpoint", "schema": "https"}'
+ )
+
+ class UnitTestDruidDbApiHook(DruidDbApiHook):
+ conn_name_attr = "druid_broker_conn_id"
+
+ self.db_hook = UnitTestDruidDbApiHook(context={'query_origin':
'airflow'})
+ self.db_hook.get_connection = MagicMock()
+ self.db_hook.get_connection.return_value = self.connection
Review Comment:
I'm not sure that we need to create new hook for testing purpose.
You could mock required methods in test cases methods +
[`pytest.mark.parametrize`](https://docs.pytest.org/en/latest/how-to/parametrize.html#pytest-mark-parametrize-parametrizing-test-functions)
##########
airflow/providers/apache/druid/hooks/druid.py:
##########
@@ -164,6 +164,10 @@ class DruidDbApiHook(DbApiHook):
hook_name = "Druid"
supports_autocommit = False
+ def __init__(self, *args, **kwargs) -> None:
+ super().__init__(*args, **kwargs)
+ self.context: dict = kwargs.pop("context", {})
Review Comment:
Better specify `context` it in `__init__` method and add it into the
docstring.
This gives more information for endusers about druid context and what the
different with airflow context
--
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]