'Test saving and restoring a state.'

def test_saving_state(self):

    entity_id = 'test.recorder'
    state = 'restoring_from_db'
    attributes = {'test_attr': 5, 'test_attr_10': 'nice'}
    self.hass.states.set(entity_id, state, attributes)
    self.hass.block_till_done()
    self.hass.data[DATA_INSTANCE].block_till_done()
    with session_scope(hass=self.hass) as session:
        db_states = list(session.query(States))
        assert (len(db_states) == 1)
        state = db_states[0].to_native()
    assert (state == self.hass.states.get(entity_id))
