Attempt to fix islamic prayer times tests (#38220)

* Attempt to fix islamic_prayer_times tests

* adj
This commit is contained in:
J. Nick Koston 2020-07-25 22:26:32 -10:00 committed by GitHub
parent 34d01d5e47
commit a39aec862e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -20,7 +20,7 @@ from tests.async_mock import patch
from tests.common import MockConfigEntry, async_fire_time_changed from tests.common import MockConfigEntry, async_fire_time_changed
async def test_setup_with_config(hass): async def test_setup_with_config(hass, legacy_patchable_time):
"""Test that we import the config and setup the client.""" """Test that we import the config and setup the client."""
config = { config = {
islamic_prayer_times.DOMAIN: {islamic_prayer_times.CONF_CALC_METHOD: "isna"} islamic_prayer_times.DOMAIN: {islamic_prayer_times.CONF_CALC_METHOD: "isna"}
@ -33,9 +33,10 @@ async def test_setup_with_config(hass):
await async_setup_component(hass, islamic_prayer_times.DOMAIN, config) await async_setup_component(hass, islamic_prayer_times.DOMAIN, config)
is True is True
) )
await hass.async_block_till_done()
async def test_successful_config_entry(hass): async def test_successful_config_entry(hass, legacy_patchable_time):
"""Test that Islamic Prayer Times is configured successfully.""" """Test that Islamic Prayer Times is configured successfully."""
entry = MockConfigEntry(domain=islamic_prayer_times.DOMAIN, data={},) entry = MockConfigEntry(domain=islamic_prayer_times.DOMAIN, data={},)
@ -46,6 +47,7 @@ async def test_successful_config_entry(hass):
return_value=PRAYER_TIMES, return_value=PRAYER_TIMES,
): ):
await hass.config_entries.async_setup(entry.entry_id) await hass.config_entries.async_setup(entry.entry_id)
await hass.async_block_till_done()
assert entry.state == config_entries.ENTRY_STATE_LOADED assert entry.state == config_entries.ENTRY_STATE_LOADED
assert entry.options == { assert entry.options == {
@ -53,7 +55,7 @@ async def test_successful_config_entry(hass):
} }
async def test_setup_failed(hass): async def test_setup_failed(hass, legacy_patchable_time):
"""Test Islamic Prayer Times failed due to an error.""" """Test Islamic Prayer Times failed due to an error."""
entry = MockConfigEntry(domain=islamic_prayer_times.DOMAIN, data={},) entry = MockConfigEntry(domain=islamic_prayer_times.DOMAIN, data={},)
@ -65,10 +67,11 @@ async def test_setup_failed(hass):
side_effect=InvalidResponseError(), side_effect=InvalidResponseError(),
): ):
await hass.config_entries.async_setup(entry.entry_id) await hass.config_entries.async_setup(entry.entry_id)
await hass.async_block_till_done()
assert entry.state == config_entries.ENTRY_STATE_SETUP_RETRY assert entry.state == config_entries.ENTRY_STATE_SETUP_RETRY
async def test_unload_entry(hass): async def test_unload_entry(hass, legacy_patchable_time):
"""Test removing Islamic Prayer Times.""" """Test removing Islamic Prayer Times."""
entry = MockConfigEntry(domain=islamic_prayer_times.DOMAIN, data={},) entry = MockConfigEntry(domain=islamic_prayer_times.DOMAIN, data={},)
entry.add_to_hass(hass) entry.add_to_hass(hass)
@ -95,6 +98,7 @@ async def test_islamic_prayer_times_timestamp_format(hass, legacy_patchable_time
return_value=PRAYER_TIMES, return_value=PRAYER_TIMES,
), patch("homeassistant.util.dt.now", return_value=NOW): ), patch("homeassistant.util.dt.now", return_value=NOW):
await hass.config_entries.async_setup(entry.entry_id) await hass.config_entries.async_setup(entry.entry_id)
await hass.async_block_till_done()
assert ( assert (
hass.data[islamic_prayer_times.DOMAIN].prayer_times_info hass.data[islamic_prayer_times.DOMAIN].prayer_times_info