Fix get_test_metadata to use test_id

The API should use test_id to get all the metadata.

Change-Id: I99a3b1ebf6dc80378d2d5da28ad273702f9fad71
This commit is contained in:
Dong Ma 2016-04-11 15:14:02 +08:00
parent 7e8a89cf29
commit daf7eedd79
3 changed files with 18 additions and 1 deletions

View File

@ -0,0 +1,3 @@
---
fixes:
- Fix get_test_metadata DB API using test_id to get all metadata.

View File

@ -446,7 +446,7 @@ def get_test_metadata(test_id, session=None):
"""
session = session or get_session()
query = db_utils.model_query(models.TestMetadata, session).filter_by(
id=test_id)
test_id=test_id)
return query.all()

View File

@ -776,3 +776,17 @@ class TestDatabaseAPI(base.TestCase):
self.assertIn(run_a.id, [x.run_id for x in res])
self.assertIn(run_b.id, [x.run_id for x in res])
self.assertIn(run_c.id, [x.run_id for x in res])
def test_get_test_metadata(self):
test = api.create_test('fake_test')
test_meta = {
'test_a': 'a',
'test_b': 'b',
'test_c': 'c',
}
api.add_test_metadata(test_meta, test.id)
test_metadata = api.get_test_metadata(test.id)
self.assertEqual(3, len(test_metadata))
for meta in test_metadata:
self.assertIn(meta.key, test_meta.keys())
self.assertIn(meta.value, test_meta.values())