mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 12:59:34 +00:00
Add config entry to iOS (#16580)
* Add config entry to iOS * Add translation
This commit is contained in:
61
tests/components/ios/test_init.py
Normal file
61
tests/components/ios/test_init.py
Normal file
@@ -0,0 +1,61 @@
|
||||
"""Tests for the iOS init file."""
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
from homeassistant import config_entries, data_entry_flow
|
||||
from homeassistant.setup import async_setup_component
|
||||
from homeassistant.components import ios
|
||||
|
||||
from tests.common import mock_component, mock_coro
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def mock_load_json():
|
||||
"""Mock load_json."""
|
||||
with patch('homeassistant.components.ios.load_json', return_value={}):
|
||||
yield
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def mock_dependencies(hass):
|
||||
"""Mock dependencies loaded."""
|
||||
mock_component(hass, 'zeroconf')
|
||||
mock_component(hass, 'device_tracker')
|
||||
|
||||
|
||||
async def test_creating_entry_sets_up_sensor(hass):
|
||||
"""Test setting up iOS loads the sensor component."""
|
||||
with patch('homeassistant.components.sensor.ios.async_setup_entry',
|
||||
return_value=mock_coro(True)) as mock_setup:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
ios.DOMAIN, context={'source': config_entries.SOURCE_USER})
|
||||
assert result['type'] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert len(mock_setup.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_configuring_ios_creates_entry(hass):
|
||||
"""Test that specifying config will create an entry."""
|
||||
with patch('homeassistant.components.ios.async_setup_entry',
|
||||
return_value=mock_coro(True)) as mock_setup:
|
||||
await async_setup_component(hass, ios.DOMAIN, {
|
||||
'ios': {
|
||||
'push': {}
|
||||
}
|
||||
})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert len(mock_setup.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_not_configuring_ios_not_creates_entry(hass):
|
||||
"""Test that no config will not create an entry."""
|
||||
with patch('homeassistant.components.ios.async_setup_entry',
|
||||
return_value=mock_coro(True)) as mock_setup:
|
||||
await async_setup_component(hass, ios.DOMAIN, {})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert len(mock_setup.mock_calls) == 0
|
||||
Reference in New Issue
Block a user