Black
This commit is contained in:
1 parent
da05dfe708
commit
4de97abc3a
2676 files changed
+163166
-140084
No files matched your search
@@ -8,19 +8,14 @@ from tests.common import MockConfigEntry
|
||||
|
||||
async def test_config_yaml_host_not_imported(hass):
|
||||
"""Test that we don't import a configured host."""
|
||||
MockConfigEntry(
|
||||
domain='tradfri',
|
||||
data={'host': 'mock-host'}
|
||||
).add_to_hass(hass)
|
||||
MockConfigEntry(domain="tradfri", data={"host": "mock-host"}).add_to_hass(hass)
|
||||
|
||||
with patch('homeassistant.components.tradfri.load_json',
|
||||
return_value={}), \
|
||||
patch.object(hass.config_entries.flow, 'async_init') as mock_init:
|
||||
assert await async_setup_component(hass, 'tradfri', {
|
||||
'tradfri': {
|
||||
'host': 'mock-host'
|
||||
}
|
||||
})
|
||||
with patch(
|
||||
"homeassistant.components.tradfri.load_json", return_value={}
|
||||
), patch.object(hass.config_entries.flow, "async_init") as mock_init:
|
||||
assert await async_setup_component(
|
||||
hass, "tradfri", {"tradfri": {"host": "mock-host"}}
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert len(mock_init.mock_calls) == 0
|
||||
@@ -28,34 +23,27 @@ async def test_config_yaml_host_not_imported(hass):
|
||||
|
||||
async def test_config_yaml_host_imported(hass):
|
||||
"""Test that we import a configured host."""
|
||||
with patch('homeassistant.components.tradfri.load_json',
|
||||
return_value={}):
|
||||
assert await async_setup_component(hass, 'tradfri', {
|
||||
'tradfri': {
|
||||
'host': 'mock-host'
|
||||
}
|
||||
})
|
||||
with patch("homeassistant.components.tradfri.load_json", return_value={}):
|
||||
assert await async_setup_component(
|
||||
hass, "tradfri", {"tradfri": {"host": "mock-host"}}
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
progress = hass.config_entries.flow.async_progress()
|
||||
assert len(progress) == 1
|
||||
assert progress[0]['handler'] == 'tradfri'
|
||||
assert progress[0]['context'] == {'source': 'import'}
|
||||
assert progress[0]["handler"] == "tradfri"
|
||||
assert progress[0]["context"] == {"source": "import"}
|
||||
|
||||
|
||||
async def test_config_json_host_not_imported(hass):
|
||||
"""Test that we don't import a configured host."""
|
||||
MockConfigEntry(
|
||||
domain='tradfri',
|
||||
data={'host': 'mock-host'}
|
||||
).add_to_hass(hass)
|
||||
MockConfigEntry(domain="tradfri", data={"host": "mock-host"}).add_to_hass(hass)
|
||||
|
||||
with patch('homeassistant.components.tradfri.load_json',
|
||||
return_value={'mock-host': {'key': 'some-info'}}), \
|
||||
patch.object(hass.config_entries.flow, 'async_init') as mock_init:
|
||||
assert await async_setup_component(hass, 'tradfri', {
|
||||
'tradfri': {}
|
||||
})
|
||||
with patch(
|
||||
"homeassistant.components.tradfri.load_json",
|
||||
return_value={"mock-host": {"key": "some-info"}},
|
||||
), patch.object(hass.config_entries.flow, "async_init") as mock_init:
|
||||
assert await async_setup_component(hass, "tradfri", {"tradfri": {}})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert len(mock_init.mock_calls) == 0
|
||||
@@ -63,14 +51,14 @@ async def test_config_json_host_not_imported(hass):
|
||||
|
||||
async def test_config_json_host_imported(hass, mock_gateway_info):
|
||||
"""Test that we import a configured host."""
|
||||
with patch('homeassistant.components.tradfri.load_json',
|
||||
return_value={'mock-host': {'key': 'some-info'}}):
|
||||
assert await async_setup_component(hass, 'tradfri', {
|
||||
'tradfri': {}
|
||||
})
|
||||
with patch(
|
||||
"homeassistant.components.tradfri.load_json",
|
||||
return_value={"mock-host": {"key": "some-info"}},
|
||||
):
|
||||
assert await async_setup_component(hass, "tradfri", {"tradfri": {}})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
progress = hass.config_entries.flow.async_progress()
|
||||
assert len(progress) == 1
|
||||
assert progress[0]['handler'] == 'tradfri'
|
||||
assert progress[0]['context'] == {'source': 'import'}
|
||||
assert progress[0]["handler"] == "tradfri"
|
||||
assert progress[0]["context"] == {"source": "import"}
|
||||
Reference in new issue
Block a user