From 70a8fcd246c9464923251969ff66a07f9afd3ac4 Mon Sep 17 00:00:00 2001 From: shanyunfan33 Date: Sun, 11 Sep 2022 14:42:09 +0800 Subject: [PATCH] add mock.patch to test_generate_must_upper add mock.patch to test_generate_must_upper method Change-Id: I943f83bc60d5a6cf4e61e311375a139cc55e891a --- venus/tests/unit/api/test_search_action.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/venus/tests/unit/api/test_search_action.py b/venus/tests/unit/api/test_search_action.py index a7f8b92..3c31f6f 100644 --- a/venus/tests/unit/api/test_search_action.py +++ b/venus/tests/unit/api/test_search_action.py @@ -245,7 +245,12 @@ class TestSearchAction(unittest.TestCase): expected = {'code': 1, 'msg': 'OK', "values": ['val1', 'val2']} 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() result = action.generate_must({'log_level.keyword': 'test'}) expected = [{'terms': {'log_level.keyword': ['test', 'TEST']}}]