kaxil commented on code in PR #76752:
URL: https://github.com/apache/airflow/pull/76752#discussion_r4532077639
##########
providers/common/ai/tests/unit/common/ai/tools/test_tools.py:
##########
@@ -153,6 +165,183 @@ def airflow_tools(self) -> list[AirflowTool]:
with pytest.raises(NotImplementedError, match="^not yet$"):
_collect_tools([_Unfinished()], mcp_hint="Connect Acme's McpClient
instead.")
+ def test_a_mock_toolset_is_asked_for_its_tools(self):
Review Comment:
Done.
##########
providers/common/ai/tests/unit/common/ai/tools/test_tools.py:
##########
@@ -153,6 +165,183 @@ def airflow_tools(self) -> list[AirflowTool]:
with pytest.raises(NotImplementedError, match="^not yet$"):
_collect_tools([_Unfinished()], mcp_hint="Connect Acme's McpClient
instead.")
+ def test_a_mock_toolset_is_asked_for_its_tools(self):
+ """The mock has ``airflow_tools`` only through ``__getattr__``, which
a Protocol check misses on Python 3.12+."""
+ source = MagicMock(spec=["airflow_tools"])
+ source.airflow_tools.return_value = [_named("a")]
+
+ assert [tool.name for tool in collect_tools([source])] == ["a"]
+
+
+def _sql_toolset(name: str = "Ada") -> SQLToolset:
+ ts = SQLToolset("pg_default")
+ ts._hook = _make_mock_db_hook(records=[(1, name)],
last_description=[("id",), ("name",)])
+ return ts
+
+
+def _names(tools: list[AirflowTool]) -> list[str]:
+ return [tool.name for tool in tools]
+
+
+def _not_query(ctx: RunContext[Any], tool: ToolDefinition) -> bool:
+ return tool.name != "query"
+
+
+async def _not_query_async(ctx: RunContext[Any], tool: ToolDefinition) -> bool:
Review Comment:
Done.
--
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]