Skip to content

ERROR:homeassistant.loader:Unable to resolve dependencies for rag_search: unable to resolve (sub)dependency aiohttp #202

@avishayil

Description

@avishayil

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions