From 5d3f922bcfb5849551f9908bd6cedc81c3c463e5 Mon Sep 17 00:00:00 2001 From: hejunli Date: Thu, 8 Sep 2022 15:00:02 +0800 Subject: [PATCH] Add test case for params Add 'no data, no buckets' test case for test_search_action.py. Change-Id: I92afb794e731649c069e33a1fd81f75fb84bae70 --- venus/tests/unit/api/test_search_action.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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')