uranusjr commented on code in PR #23888:
URL: https://github.com/apache/airflow/pull/23888#discussion_r884435385
##########
tests/providers/elasticsearch/log/elasticmock/fake_elasticsearch.py:
##########
@@ -362,6 +363,18 @@ def match_must_phrase(document, matches, must):
# use in as a proxy for match_phrase
matches.append(document)
+ # Check index(es) exists
+ def _validate_search_targets(self, targets):
+ matches = set()
+ for target in targets:
+ if target == '_all':
+ matches.update(self.__documents_dict.keys())
+ elif '*' in target:
+ matches.update(fnmatch.filter(self.__documents_dict.keys(),
target))
+ elif target not in self.__documents_dict:
+ raise NotFoundError(404, f'IndexMissingException[[{target}]
missing]')
Review Comment:
The `keys()` calls are not needed.
Given that a wildcard match is ignored if it does not match anything, we
probably should do the same about normal names.
```suggestion
if target == '_all':
matches.update(self.__documents_dic)
else:
matches.update(fnmatch.filter(self.__documents_dict, target))
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]