mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 12:59:34 +00:00
Black
This commit is contained in:
@@ -13,30 +13,32 @@ 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={}):
|
||||
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')
|
||||
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.ios.sensor.async_setup_entry',
|
||||
return_value=mock_coro(True)) as mock_setup:
|
||||
with patch(
|
||||
"homeassistant.components.ios.sensor.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})
|
||||
ios.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
# Confirmation form
|
||||
assert result['type'] == data_entry_flow.RESULT_TYPE_FORM
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result['flow_id'], {})
|
||||
assert result['type'] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
||||
result = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
@@ -45,13 +47,10 @@ async def test_creating_entry_sets_up_sensor(hass):
|
||||
|
||||
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': {}
|
||||
}
|
||||
})
|
||||
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
|
||||
@@ -59,8 +58,9 @@ async def test_configuring_ios_creates_entry(hass):
|
||||
|
||||
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:
|
||||
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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user