* Bump openai * Fix tests * Apply suggestions from code review * Undo conftest changes * Raise repasir issue * Explicitly use async mock for chat.completions.create It is not always detected correctly as async because it uses a decorator * removed duplicated message * ruff * Compatibility with old pydantic versions * Compatibility with old pydantic versions * More tests * Apply suggestions from code review Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * Apply suggestions from code review --------- Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
31 lines
719 B
Python
31 lines
719 B
Python
"""Tests helpers."""
|
|
from unittest.mock import patch
|
|
|
|
import pytest
|
|
|
|
from homeassistant.setup import async_setup_component
|
|
|
|
from tests.common import MockConfigEntry
|
|
|
|
|
|
@pytest.fixture
|
|
def mock_config_entry(hass):
|
|
"""Mock a config entry."""
|
|
entry = MockConfigEntry(
|
|
domain="openai_conversation",
|
|
data={
|
|
"api_key": "bla",
|
|
},
|
|
)
|
|
entry.add_to_hass(hass)
|
|
return entry
|
|
|
|
|
|
@pytest.fixture
|
|
async def mock_init_component(hass, mock_config_entry):
|
|
"""Initialize integration."""
|
|
with patch(
|
|
"openai.resources.models.AsyncModels.list",
|
|
):
|
|
assert await async_setup_component(hass, "openai_conversation", {})
|
|
await hass.async_block_till_done()
|