1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-26 22:18:40 +00:00

Add missing hass type hint in component tests (g) (#124203)

This commit is contained in:
epenet
2024-08-19 09:29:26 +02:00
committed by GitHub
parent 1fdcbc3f15
commit 25d33e96cc
7 changed files with 57 additions and 36 deletions

View File

@@ -1,5 +1,6 @@
"""Tests for the Google Generative AI Conversation integration conversation platform."""
from typing import Any
from unittest.mock import AsyncMock, MagicMock, patch
from freezegun import freeze_time
@@ -215,7 +216,9 @@ async def test_function_call(
},
)
def tool_call(hass, tool_input, tool_context):
def tool_call(
hass: HomeAssistant, tool_input: llm.ToolInput, tool_context: llm.LLMContext
) -> dict[str, Any]:
mock_part.function_call = None
mock_part.text = "Hi there!"
return {"result": "Test response"}
@@ -314,7 +317,9 @@ async def test_function_call_without_parameters(
mock_part = MagicMock()
mock_part.function_call = FunctionCall(name="test_tool", args={})
def tool_call(hass, tool_input, tool_context):
def tool_call(
hass: HomeAssistant, tool_input: llm.ToolInput, tool_context: llm.LLMContext
) -> dict[str, Any]:
mock_part.function_call = None
mock_part.text = "Hi there!"
return {"result": "Test response"}
@@ -400,7 +405,9 @@ async def test_function_exception(
mock_part = MagicMock()
mock_part.function_call = FunctionCall(name="test_tool", args={"param1": 1})
def tool_call(hass, tool_input, tool_context):
def tool_call(
hass: HomeAssistant, tool_input: llm.ToolInput, tool_context: llm.LLMContext
) -> dict[str, Any]:
mock_part.function_call = None
mock_part.text = "Hi there!"
raise HomeAssistantError("Test tool exception")