From e41c086e7c93c0350cbd94794b1a3912e96e2935 Mon Sep 17 00:00:00 2001 From: shanyunfan33 Date: Sun, 11 Sep 2022 14:27:45 +0800 Subject: [PATCH] add @mock.patch to test_get_all_index add @mock.patch to test_get_all_index method Change-Id: Id201272f675085d2774e6bc390aaa2529159c4e4 --- venus/tests/unit/api/test_search_action.py | 6 +++++- 1 file changed, 5 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..54416e6 100644 --- a/venus/tests/unit/api/test_search_action.py +++ b/venus/tests/unit/api/test_search_action.py @@ -131,8 +131,12 @@ class TestSearchAction(unittest.TestCase): index_names = self.action.get_all_index('test_index') self.assertEqual("", index_names) + @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_get_all_index(self, mock_req_es): + def test_get_all_index( + 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' mock_req_es.return_value = ( 200, '[{"index":"index1"},{"index":"index2"}]') index_names = self.action.get_all_index('test_index')