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

Using mock custom components from core #170

Open
ScottG489 opened this issue Oct 22, 2023 · 2 comments
Open

Using mock custom components from core #170

ScottG489 opened this issue Oct 22, 2023 · 2 comments

Comments

@ScottG489
Copy link

Core has a variety of components mocked out so entities can be created and and interacted with in tests.

Would we ever consider including these mocks into this project so they can be used in custom component tests?

I believe this is somewhat what we're already doing for recorder, but I could be misunderstanding what that's here for exactly.

I think my use case is somewhat unusual since I'm writing an integration that focuses on automation logic that interacts with other different components, whereas typically a custom component would only care about it's own domain. So I'd be interested in hearing your thoughts.

@ScottG489
Copy link
Author

Another option may be to allow devs to add these mocked custom components themselves. Although it could be beneficial to keep them synced with core, at least this way we could just write our own test custom components.

I think this could be done by overriding how get_test_config_dir() works which currently points to somewhere in the phacc dependency dir (i.e. [...]/site-packages/pytest_homeassistant_custom_component/testing_config) which obviously doesn't exist. Instead it could point to somewhere in the custom component's project such as tests/testing_config.

@MatthewFlamm
Copy link
Owner

If all we have to do is copy over the entire testing_config folder, then this sounds fairly easy. We need part of that folder now anyway since the top level testing code now imports from within that structure.

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

No branches or pull requests

2 participants