def get_tests_run_dicts_from_run_id(run_id, session=None):
    session = session or get_session()
    query = db_utils.model_query(models.Test, session=session).join(
        models.TestRun, models.Test.id == models.TestRun.test_id).join(
            models.Run, models.TestRun.run_id == models.Run.id).filter(
                models.Run.uuid == run_id).outerjoin(
                    models.TestRunMetadata,
                    models.TestRun.id == models.TestRunMetadata.
                    test_run_id).order_by(
                        models.TestRun.start_time,
                        models.TestRun.start_time_microsecond).values(
                            models.Test.test_id,
                            models.TestRun.status,
                            models.TestRun.start_time,
                            models.TestRun.start_time_microsecond,
                            models.TestRun.stop_time,
                            models.TestRun.stop_time_microsecond,
                            models.TestRunMetadata.key,
                            models.TestRunMetadata.value)
    test_runs = collections.OrderedDict()
    for test_run in query:
        if test_run[0] not in test_runs:
            # If there is no start_time set to None
            if test_run[2]:
                start_time = test_run[2]
                start_time = start_time.replace(microsecond=test_run[3])
            else:
                start_time = None
            # If there is no stop_time set to None
            if test_run[4]:
                stop_time = test_run[4]
                stop_time = stop_time.replace(microsecond=test_run[5])
            else:
                stop_time = None
            test_runs[test_run[0]] = {
                'status': test_run[1],
                'start_time': start_time,
                'stop_time': stop_time,
            }
            if test_run[6]:
                test_runs[test_run[0]]['metadata'] = {test_run[6]: test_run[7]}
        else:
            if test_run[6]:
                test_runs[test_run[0]]['metadata'][test_run[6]] = test_run[7]
    return test_runs
Returns all the stored data about test runs for a specific run.
dataset/ETHPy150Open openstack-infra/subunit2sql/subunit2sql/db/api.py/get_tests_run_dicts_from_run_id