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

def test_openalpr_process_image(self, aioclient_mock):

    aioclient_mock.get(self.url, content='image')
    aioclient_mock.post(OPENALPR_API_URL, params=self.params, text=load_fixture('alpr_cloud.json'), status=200)
    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 (len(aioclient_mock.mock_calls) == 2)
    assert (len(self.alpr_events) == 5)
    assert (state.attributes.get('vehicles') == 1)
    assert (state.state == 'H786P0J')
    event_data = [event.data for event in self.alpr_events if (event.data.get('plate') == 'H786P0J')]
    assert (len(event_data) == 1)
    assert (event_data[0]['plate'] == 'H786P0J')
    assert (event_data[0]['confidence'] == float(90.436699))
    assert (event_data[0]['entity_id'] == 'image_processing.test_local')
