Hello, I'm using the aiohttp dependency in my custom component.
I'm trying to set unit testing using this component. My conftest.py looks like this:
import pytest
from unittest.mock import patch
from homeassistant import config_entries
from homeassistant.core import HomeAssistant
from homeassistant.setup import async_setup_component
from custom_components.rag_search.const import DOMAIN
pytest_plugins = "pytest_homeassistant_custom_component"
@pytest.fixture(autouse=True)
def auto_enable_custom_integrations(enable_custom_integrations):
"""Enable custom integrations."""
return enable_custom_integrations
@pytest.fixture
async def setup_config_entry(hass: HomeAssistant):
"""Set up the RAG Search component with a config entry."""
config_entry = config_entries.ConfigEntry(
version=1,
domain=DOMAIN,
title="RAG Search",
data={
"openai_api_key": "test_api_key",
"openai_model": "gpt-4-turbo",
"entity_scope": ["sensor.test_sensor"],
"max_items": 5,
"timeout": 15,
},
source="test_source",
state=config_entries.ConfigEntryState.NOT_LOADED,
entry_id="test",
unique_id="unique_test_id",
options={},
minor_version=0,
discovery_keys=None,
)
hass.config_entries.async_entries(DOMAIN).append(config_entry)
with patch(
"custom_components.rag_search.async_setup_entry", return_value=True
) as mock_setup:
assert await async_setup_component(hass, DOMAIN, {})
await hass.async_block_till_done()
return config_entry
I'm getting the following error while running any test with this fixture:
DEBUG:asyncio:Using selector: KqueueSelector
DEBUG:asyncio:Using selector: KqueueSelector
DEBUG:homeassistant.helpers.restore_state:Not creating cache - no saved states found
INFO:homeassistant.loader:Loaded rag_search from custom_components.rag_search
WARNING:homeassistant.loader:We found a custom integration rag_search which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
ERROR:homeassistant.loader:Unable to resolve dependencies for rag_search: unable to resolve (sub)dependency aiohttp
aiohttp is a required dependency for the plugin to work. What can I do in order to support it in the tests?
Hello, I'm using the
aiohttpdependency in my custom component.I'm trying to set unit testing using this component. My
conftest.pylooks like this:I'm getting the following error while running any test with this fixture:
aiohttpis a required dependency for the plugin to work. What can I do in order to support it in the tests?