async def test_failed_test_connection(hass, mock_get_eventhub_properties): """Test being able to unload an entry.""" entry = MockConfigEntry( domain=azure_event_hub.DOMAIN, data=SAS_CONFIG_FULL, title="test-instance", options=BASIC_OPTIONS, ) entry.add_to_hass(hass) mock_get_eventhub_properties.side_effect = EventHubError("Test") await hass.config_entries.async_setup(entry.entry_id) assert entry.state == ConfigEntryState.SETUP_RETRY
async def test_send_batch_error(hass, entry_with_one_event, mock_send_batch): """Test a error in send_batch, including recovering at the next interval.""" mock_send_batch.reset_mock() mock_send_batch.side_effect = [EventHubError("Test"), None] async_fire_time_changed( hass, utcnow() + timedelta(seconds=entry_with_one_event.options[CONF_SEND_INTERVAL]), ) await hass.async_block_till_done() mock_send_batch.assert_called_once() mock_send_batch.reset_mock() hass.states.async_set("sensor.test2", STATE_ON) async_fire_time_changed( hass, utcnow() + timedelta(seconds=entry_with_one_event.options[CONF_SEND_INTERVAL]), ) await hass.async_block_till_done() mock_send_batch.assert_called_once()
async def receive(self): raise EventHubError("Mock EventHubConsumer EventHubError")
async def receive(self, *args, **kwargs): raise EventHubError("Mock EventHubConsumer EventHubError")
def receive(self, *args, **kwargs): time.sleep(0.5) raise EventHubError("Mock EventHubConsumer EventHubError")
title="test-instance", ) entry.add_to_hass(hass) result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": source}, data=BASE_CONFIG_CS.copy(), ) assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT assert result["reason"] == "single_instance_allowed" @pytest.mark.parametrize( "side_effect, error_message", [(EventHubError("test"), "cannot_connect"), (Exception, "unknown")], ids=["cannot_connect", "unknown"], ) async def test_connection_error_sas( hass, mock_get_eventhub_properties, side_effect, error_message, ): """Test we handle connection errors.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER}, data=BASE_CONFIG_SAS.copy(), ) assert result["type"] == "form"
def receive(self): time.sleep(0.5) raise EventHubError("Mock EventHubConsumer EventHubError")