From de7f5483945cef8b9859b595f37b37aa4345ac71 Mon Sep 17 00:00:00 2001 From: Shashank Reddy Boyapally Date: Wed, 27 Mar 2024 12:16:35 -0400 Subject: [PATCH] uuids to include buildUrls (#23) Signed-off-by: Shashank Reddy Boyapally --- fmatch/matcher.py | 5 +++-- fmatch/tests/test_matcher.py | 10 ++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/fmatch/matcher.py b/fmatch/matcher.py index 7928242..543ba40 100644 --- a/fmatch/matcher.py +++ b/fmatch/matcher.py @@ -92,8 +92,9 @@ def get_uuid_by_metadata(self, meta, index=None): s = Search(using=self.es, index=index).query(query).extra(size=self.search_size) result = self.query_index(index, s) hits = result.hits.hits - uuids = [hit.to_dict()["_source"]["uuid"] for hit in hits] - return uuids + uuids_docs = [{ "uuid":hit.to_dict()["_source"]["uuid"], + "buildUrl":hit.to_dict()["_source"]["buildUrl"]} for hit in hits] + return uuids_docs def match_kube_burner(self, uuids): """match kube burner runs diff --git a/fmatch/tests/test_matcher.py b/fmatch/tests/test_matcher.py index ba1f4cc..6b7d51b 100644 --- a/fmatch/tests/test_matcher.py +++ b/fmatch/tests/test_matcher.py @@ -59,7 +59,10 @@ def test_query_index(matcher_instance): def test_get_uuid_by_metadata(matcher_instance): matcher_instance.es.search = lambda *args, **kwargs: { "hits": { - "hits": [{"_source": {"uuid": "uuid1"}}, {"_source": {"uuid": "uuid2"}}] + "hits": [{"_source": {"uuid": "uuid1", + "buildUrl":"buildUrl1"}}, + {"_source": {"uuid": "uuid2", + "buildUrl":"buildUrl1"}}] } } meta = { @@ -67,7 +70,10 @@ def test_get_uuid_by_metadata(matcher_instance): "ocpVersion": "4.15", } result = matcher_instance.get_uuid_by_metadata(meta) - expected = ["uuid1", "uuid2"] + expected = [{"uuid": "uuid1", + "buildUrl":"buildUrl1"}, + {"uuid": "uuid2", + "buildUrl":"buildUrl1"}] assert result == expected