@asyncio.coroutine
def test_platform_not_ready(hass):
    'Test that we retry when platform not ready.'
    platform1_setup = Mock(side_effect=[PlatformNotReady, PlatformNotReady, None])
    loader.set_component(hass, 'mod1', MockModule('mod1'))
    loader.set_component(hass, 'mod1.test_domain', MockPlatform(platform1_setup))
    component = EntityComponent(_LOGGER, DOMAIN, hass)
    (yield from component.async_setup({DOMAIN: {'platform': 'mod1'}}))
    assert (len(platform1_setup.mock_calls) == 1)
    assert ('test_domain.mod1' not in hass.config.components)
    utcnow = dt_util.utcnow()
    with patch('homeassistant.util.dt.utcnow', return_value=utcnow):
        async_fire_time_changed(hass, (utcnow + timedelta(seconds=29)))
        (yield from hass.async_block_till_done())
        assert (len(platform1_setup.mock_calls) == 1)
        async_fire_time_changed(hass, (utcnow + timedelta(seconds=30)))
        (yield from hass.async_block_till_done())
        assert (len(platform1_setup.mock_calls) == 2)
        assert ('test_domain.mod1' not in hass.config.components)
        async_fire_time_changed(hass, (utcnow + timedelta(seconds=59)))
        (yield from hass.async_block_till_done())
        assert (len(platform1_setup.mock_calls) == 2)
        async_fire_time_changed(hass, (utcnow + timedelta(seconds=60)))
        (yield from hass.async_block_till_done())
        assert (len(platform1_setup.mock_calls) == 3)
        assert ('test_domain.mod1' in hass.config.components)
Test that we retry when platform not ready.
@asyncio.coroutine
def test_platform_not_ready(hass):
    
    platform1_setup = Mock(side_effect=[PlatformNotReady, PlatformNotReady, None])
    loader.set_component(hass, 'mod1', MockModule('mod1'))
    loader.set_component(hass, 'mod1.test_domain', MockPlatform(platform1_setup))
    component = EntityComponent(_LOGGER, DOMAIN, hass)
    (yield from component.async_setup({DOMAIN: {'platform': 'mod1'}}))
    assert (len(platform1_setup.mock_calls) == 1)
    assert ('test_domain.mod1' not in hass.config.components)
    utcnow = dt_util.utcnow()
    with patch('homeassistant.util.dt.utcnow', return_value=utcnow):
        async_fire_time_changed(hass, (utcnow + timedelta(seconds=29)))
        (yield from hass.async_block_till_done())
        assert (len(platform1_setup.mock_calls) == 1)
        async_fire_time_changed(hass, (utcnow + timedelta(seconds=30)))
        (yield from hass.async_block_till_done())
        assert (len(platform1_setup.mock_calls) == 2)
        assert ('test_domain.mod1' not in hass.config.components)
        async_fire_time_changed(hass, (utcnow + timedelta(seconds=59)))
        (yield from hass.async_block_till_done())
        assert (len(platform1_setup.mock_calls) == 2)
        async_fire_time_changed(hass, (utcnow + timedelta(seconds=60)))
        (yield from hass.async_block_till_done())
        assert (len(platform1_setup.mock_calls) == 3)
        assert ('test_domain.mod1' in hass.config.components)