DurgNomis-drol / ha_toyota

Toyota Connected Services integration for Home Assistant.
MIT License
148 stars 32 forks source link

Enhancement: POC add unit tests for custom component #180

Open CM000n opened 12 months ago

CM000n commented 12 months ago

This MR implements the possibility for unit/integration testing of the custom component. Additional help is most welcome!

CM000n commented 12 months ago

In theory, this "should" work. However, when running pytest -s -vv you currently get the following error message:

――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― ERROR at setup of test_config_form ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――

hass = <async_generator object hass at 0x7fa61083d0e0>

    @pytest.fixture
    def enable_custom_integrations(hass: HomeAssistant) -> None:
        """Enable custom integrations defined in the test dir."""
>       hass.data.pop(loader.DATA_CUSTOM_COMPONENTS)
E       AttributeError: 'async_generator' object has no attribute 'data'

../../python_envs/ha_toyota/lib/python3.11/site-packages/pytest_homeassistant_custom_component/plugins.py:1172: AttributeError
----------------------------------------------------------------------------------------------------------- Captured log setup -----------------------------------------------------------------------------------------------------------
DEBUG    asyncio:selector_events.py:54 Using selector: EpollSelector
DEBUG:asyncio:Close <_UnixSelectorEventLoop running=False closed=False debug=True>
DEBUG:asyncio:Using selector: EpollSelector

Any support is therefore more than welcome

DurgNomis-drol commented 12 months ago

Love this! But I can't help you much as I have never written custom_integration unit test, I can barely write unit test for mytoyota 😅