Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: POC add unit tests for custom component #180

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

CM000n
Copy link
Collaborator

@CM000n CM000n commented Nov 24, 2023

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

@CM000n CM000n self-assigned this Nov 24, 2023
@CM000n CM000n marked this pull request as draft November 24, 2023 10:36
@CM000n CM000n linked an issue Nov 24, 2023 that may be closed by this pull request
@CM000n
Copy link
Collaborator Author

CM000n commented Nov 24, 2023

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
Copy link
Owner

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 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enhancement: Add unit and integration tests
2 participants