Set up Met during onboarding (#24622)
* Set up Met during onboarding * Lint * Add pyMetNo to test reqs
This commit is contained in:
1 parent
6ea92f86a5
commit
f2962a0d16
12 files changed
+242
-54
No files matched your search
@@ -0,0 +1,52 @@
|
||||
"""Test Met weather entity."""
|
||||
|
||||
|
||||
async def test_tracking_home(hass, mock_weather):
|
||||
"""Test we track home."""
|
||||
await hass.config_entries.flow.async_init('met', context={
|
||||
'source': 'onboarding'
|
||||
})
|
||||
await hass.async_block_till_done()
|
||||
assert len(hass.states.async_entity_ids('weather')) == 1
|
||||
assert len(mock_weather.mock_calls) == 3
|
||||
|
||||
# Test we track config
|
||||
await hass.config.async_update(
|
||||
latitude=10,
|
||||
longitude=20,
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert len(mock_weather.mock_calls) == 6
|
||||
|
||||
entry = hass.config_entries.async_entries()[0]
|
||||
await hass.config_entries.async_remove(entry.entry_id)
|
||||
assert len(hass.states.async_entity_ids('weather')) == 0
|
||||
|
||||
|
||||
async def test_not_tracking_home(hass, mock_weather):
|
||||
"""Test when we not track home."""
|
||||
await hass.config_entries.flow.async_init('met', context={
|
||||
'source': 'user'
|
||||
}, data={
|
||||
'name': 'Somewhere',
|
||||
'latitude': 10,
|
||||
'longitude': 20,
|
||||
'elevation': 0,
|
||||
})
|
||||
await hass.async_block_till_done()
|
||||
assert len(hass.states.async_entity_ids('weather')) == 1
|
||||
assert len(mock_weather.mock_calls) == 3
|
||||
|
||||
# Test we do not track config
|
||||
await hass.config.async_update(
|
||||
latitude=10,
|
||||
longitude=20,
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert len(mock_weather.mock_calls) == 3
|
||||
|
||||
entry = hass.config_entries.async_entries()[0]
|
||||
await hass.config_entries.async_remove(entry.entry_id)
|
||||
assert len(hass.states.async_entity_ids('weather')) == 0
|
||||
Reference in new issue
Block a user