Add test case for params

Add 'no data, no buckets' test case for test_search_action.py.

Change-Id: I92afb794e731649c069e33a1fd81f75fb84bae70
This commit is contained in:
hejunli 2022-09-08 15:00:02 +08:00
parent e05065cb62
commit 5d3f922bcf

View File

@ -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')