Merge "add mock.patch to test_generate_must_upper"

This commit is contained in:
Zuul 2022-09-14 01:23:16 +00:00 committed by Gerrit Code Review
commit 6f1ef4e1de

View File

@ -259,7 +259,12 @@ class TestSearchAction(unittest.TestCase):
expected = {'code': 1, 'msg': 'OK', "values": ['val1', 'val2']} expected = {'code': 1, 'msg': 'OK', "values": ['val1', 'val2']}
self.assertEqual(expected, result) self.assertEqual(expected, result)
def test_generate_must_upper(self): @mock.patch('venus.modules.search.es_template.search_params')
@mock.patch('venus.modules.search.action.SearchCore.get_index_names')
@mock.patch('venus.common.utils.request_es')
def test_generate_must_upper(
self, mock_req_es, mock_get_index_names, mock_search_params):
mock_get_index_names.return_value = 'flog-2021.01.03,flog-2021.01.04'
action = SearchCore() action = SearchCore()
result = action.generate_must({'log_level.keyword': 'test'}) result = action.generate_must({'log_level.keyword': 'test'})
expected = [{'terms': {'log_level.keyword': ['test', 'TEST']}}] expected = [{'terms': {'log_level.keyword': ['test', 'TEST']}}]