Skip to content

Commit

Permalink
uuids to include buildUrls (#23)
Browse files Browse the repository at this point in the history
Signed-off-by: Shashank Reddy Boyapally <[email protected]>
  • Loading branch information
shashank-boyapally authored Mar 27, 2024
1 parent 0e6f6e7 commit de7f548
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
5 changes: 3 additions & 2 deletions fmatch/matcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 8 additions & 2 deletions fmatch/tests/test_matcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,21 @@ 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 = {
"field1": "value1",
"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


Expand Down

0 comments on commit de7f548

Please sign in to comment.