'Record some test states.
We inject a bunch of state updates from media player, zone and
thermostat.'

def record_states(self):

    self.init_recorder()
    mp = 'media_player.test'
    mp2 = 'media_player.test2'
    therm = 'thermostat.test'
    therm2 = 'thermostat.test2'
    zone = 'zone.home'
    script_nc = 'script.cannot_cancel_this_one'
    script_c = 'script.can_cancel_this_one'
    def set_state(entity_id, state, **kwargs):
        'Set    the    state.'
        self.hass.states.set(entity_id, state, **kwargs)
        self.wait_recording_done()
        return self.hass.states.get(entity_id)
    zero = dt_util.utcnow()
    one = (zero + timedelta(seconds=1))
    two = (one + timedelta(seconds=1))
    three = (two + timedelta(seconds=1))
    four = (three + timedelta(seconds=1))
    states = {therm: [], therm2: [], mp: [], mp2: [], script_c: []}
    with patch('homeassistant.components.recorder.dt_util.utcnow', return_value=one):
        states[mp].append(set_state(mp, 'idle', attributes={'media_title': str(sentinel.mt1)}))
        states[mp].append(set_state(mp, 'YouTube', attributes={'media_title': str(sentinel.mt2)}))
        states[mp2].append(set_state(mp2, 'YouTube', attributes={'media_title': str(sentinel.mt2)}))
        states[therm].append(set_state(therm, 20, attributes={'current_temperature': 19.5}))
    with patch('homeassistant.components.recorder.dt_util.utcnow', return_value=two):
        set_state(mp, 'YouTube', attributes={'media_title': str(sentinel.mt3)})
        set_state(zone, 'zoning')
        set_state(script_nc, 'off')
        states[script_c].append(set_state(script_c, 'off', attributes={'can_cancel': True}))
        states[therm].append(set_state(therm, 21, attributes={'current_temperature': 19.8}))
        states[therm2].append(set_state(therm2, 20, attributes={'current_temperature': 19}))
    with patch('homeassistant.components.recorder.dt_util.utcnow', return_value=three):
        states[mp].append(set_state(mp, 'Netflix', attributes={'media_title': str(sentinel.mt4)}))
        states[therm].append(set_state(therm, 21, attributes={'current_temperature': 20}))
        set_state(therm, 22, attributes={'current_temperature': 21, 'hidden': True})
    return (zero, four, states)
