From 3b2d1494e0cf033e963f1d7195376792af53304b Mon Sep 17 00:00:00 2001 From: Matthew Treinish Date: Sat, 2 Aug 2014 21:29:36 -0400 Subject: [PATCH] Add get_failing_from_run db api method This commit adds a new db api method to return a list of test_run objects that failed for a given run_id. This is needed for adding a subunit2sql based repository in testrepository. Change-Id: Ib4a283fc3abeae1ecfc74995c2ad85564b06671a --- subunit2sql/db/api.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/subunit2sql/db/api.py b/subunit2sql/db/api.py index 4e12ad5..5446b97 100644 --- a/subunit2sql/db/api.py +++ b/subunit2sql/db/api.py @@ -175,6 +175,13 @@ def get_all_test_runs(): return query.all() +def get_failing_from_run(run_id, session=None): + session = session or get_session() + query = db_utils.model_query(models.TestRun, session).filter_by( + run_id=run_id, status='fail') + return query.all() + + def get_test_by_id(id, session=None): session = session or get_session() test = db_utils.model_query(models.Test, session).filter_by(