Lee-W commented on code in PR #36014: URL: https://github.com/apache/airflow/pull/36014#discussion_r1412716698
########## tests/providers/openai/hooks/test_openai.py: ########## @@ -16,48 +16,58 @@ # under the License. from __future__ import annotations -from unittest.mock import Mock, patch +from unittest.mock import MagicMock, Mock, patch import pytest +from openai import OpenAI +from openai.types import CreateEmbeddingResponse, Embedding from airflow.providers.openai.hooks.openai import OpenAIHook @pytest.fixture def openai_hook(): - with patch("airflow.providers.openai.hooks.openai.OpenAIHook._get_api_key"), patch( - "airflow.providers.openai.hooks.openai.OpenAIHook._get_api_base" - ) as _: + with patch("airflow.providers.openai.hooks.openai.OpenAI") as _: Review Comment: May I know why do we need `as _`? ########## airflow/providers/openai/hooks/openai.py: ########## @@ -41,13 +42,9 @@ class OpenAIHook(BaseHook): def __init__(self, conn_id: str = default_conn_name, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) self.conn_id = conn_id - openai.api_key = self._get_api_key() - api_base = self._get_api_base() - if api_base: - openai.api_base = api_base - @staticmethod - def get_ui_field_behaviour() -> dict[str, Any]: + @classmethod Review Comment: May I know why do we want to change it to classmethod? -- 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: commits-unsubscr...@airflow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org