'Setup and scan a picture and test plates from event.'

@patch('asyncio.create_subprocess_exec', return_value=mock_async_subprocess())
def test_openalpr_process_image(self, popen_mock, aioclient_mock):

    aioclient_mock.get(self.url, content='image')
    ip.scan(self.hass, entity_id='image_processing.test_local')
    self.hass.block_till_done()
    state = self.hass.states.get('image_processing.test_local')
    assert popen_mock.called
    assert (len(self.alpr_events) == 5)
    assert (state.attributes.get('vehicles') == 1)
    assert (state.state == 'PE3R2X')
    event_data = [event.data for event in self.alpr_events if (event.data.get('plate') == 'PE3R2X')]
    assert (len(event_data) == 1)
    assert (event_data[0]['plate'] == 'PE3R2X')
    assert (event_data[0]['confidence'] == float(98.9371))
    assert (event_data[0]['entity_id'] == 'image_processing.test_local')
