def test_purge_old_recorder_runs(hass, hass_recorder):
    'Test deleting old recorder runs keeps current run.'
    hass = hass_recorder()
    _add_test_recorder_runs(hass)
    with session_scope(hass=hass) as session:
        recorder_runs = session.query(RecorderRuns)
        assert (recorder_runs.count() == 7)
        finished = purge_old_data(hass.data[DATA_INSTANCE], 0, repack=False)
        assert finished
        assert (recorder_runs.count() == 1)
Test deleting old recorder runs keeps current run.
def test_purge_old_recorder_runs(hass, hass_recorder):
    
    hass = hass_recorder()
    _add_test_recorder_runs(hass)
    with session_scope(hass=hass) as session:
        recorder_runs = session.query(RecorderRuns)
        assert (recorder_runs.count() == 7)
        finished = purge_old_data(hass.data[DATA_INSTANCE], 0, repack=False)
        assert finished
        assert (recorder_runs.count() == 1)