diff --git a/venus/tests/unit/api/test_search_action.py b/venus/tests/unit/api/test_search_action.py index dc3872e..a7f8b92 100644 --- a/venus/tests/unit/api/test_search_action.py +++ b/venus/tests/unit/api/test_search_action.py @@ -205,6 +205,19 @@ class TestSearchAction(unittest.TestCase): expected = {"code": 0, "msg": "no data, no values"} self.assertEqual(expected, result) + @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_params_no_buckets( + 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, '{"aggregations": {"search_values": {}}}') + action = SearchCore() + result = action.params('host_name', '', None) + expected = {"code": 0, "msg": "no data, no buckets"} + self.assertEqual(expected, result) + @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')