1
0
mirror of https://github.com/home-assistant/core.git synced 2025-08-13 15:30:03 +00:00
Files
.devcontainer
.github
.vscode
docs
homeassistant
script
tests
auth
components
fixtures
hassfest
helpers
__init__.py
test_aiohttp_client.py
test_area_registry.py
test_check_config.py
test_collection.py
test_condition.py
test_config_entry_flow.py
test_config_entry_oauth2_flow.py
test_config_validation.py
test_debounce.py
test_deprecation.py
test_device_registry.py
test_discovery.py
test_dispatcher.py
test_entity.py
test_entity_component.py
test_entity_platform.py
test_entity_registry.py
test_entity_values.py
test_entityfilter.py
test_event.py
test_icon.py
test_init.py
test_integration_platform.py
test_intent.py
test_json.py
test_location.py
test_network.py
test_restore_state.py
test_script.py
test_service.py
test_state.py
test_storage.py
test_sun.py
test_system_info.py
test_temperature.py
test_template.py
test_translation.py
test_update_coordinator.py
mock
resources
scripts
test_util
testing_config
util
__init__.py
bandit.yaml
common.py
conftest.py
test_bootstrap.py
test_config.py
test_config_entries.py
test_core.py
test_data_entry_flow.py
test_loader.py
test_main.py
test_requirements.py
test_setup.py
.coveragerc
.dockerignore
.gitattributes
.gitignore
.ignore
.pre-commit-config.yaml
.readthedocs.yml
.travis.yml
CLA.md
CODEOWNERS
CODE_OF_CONDUCT.md
CONTRIBUTING.md
Dockerfile.dev
LICENSE.md
MANIFEST.in
README.rst
azure-pipelines-ci.yml
azure-pipelines-release.yml
azure-pipelines-translation.yml
azure-pipelines-wheels.yml
codecov.yml
pylintrc
pyproject.toml
requirements_all.txt
requirements_docs.txt
requirements_test.txt
requirements_test_all.txt
requirements_test_pre_commit.txt
setup.cfg
setup.py
tox.ini
core/tests/helpers/test_integration_platform.py
2019-12-13 15:38:41 +01:00

38 lines
1.1 KiB
Python

"""Test integration platform helpers."""
from unittest.mock import Mock
from homeassistant.setup import ATTR_COMPONENT, EVENT_COMPONENT_LOADED
from tests.common import mock_platform
async def test_process_integration_platforms(hass):
"""Test processing integrations."""
loaded_platform = Mock()
mock_platform(hass, "loaded.platform_to_check", loaded_platform)
hass.config.components.add("loaded")
event_platform = Mock()
mock_platform(hass, "event.platform_to_check", event_platform)
processed = []
async def _process_platform(hass, domain, platform):
"""Process platform."""
processed.append((domain, platform))
await hass.helpers.integration_platform.async_process_integration_platforms(
"platform_to_check", _process_platform
)
assert len(processed) == 1
assert processed[0][0] == "loaded"
assert processed[0][1] == loaded_platform
hass.bus.async_fire(EVENT_COMPONENT_LOADED, {ATTR_COMPONENT: "event"})
await hass.async_block_till_done()
assert len(processed) == 2
assert processed[1][0] == "event"
assert processed[1][1] == event_platform