From df17f84874c1b48ab8921ab74b6786026d296329 Mon Sep 17 00:00:00 2001 From: hejunli Date: Wed, 24 Aug 2022 10:50:28 +0800 Subject: [PATCH] Supplement test case for typical_stats Add 'no data, no data group' test case of typical_stats to test_search_action.py. Change-Id: Iecc0692ec148e3097996cd60bb7720f21f08dbc0 --- 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 448e883..0953e11 100644 --- a/venus/tests/unit/api/test_search_action.py +++ b/venus/tests/unit/api/test_search_action.py @@ -464,6 +464,19 @@ class TestSearchAction(unittest.TestCase): expected = {"code": 0, "msg": "no data, no aggregations"} self.assertEqual(expected, result) + @mock.patch('venus.modules.search.es_template.search_logs') + @mock.patch('venus.modules.search.action.SearchCore.get_index_names') + @mock.patch('venus.common.utils.request_es') + def test_typical_stats_no_data_group( + self, mock_req_es, mock_get_index_names, mock_search_logs): + action = SearchCore() + mock_get_index_names.return_value = 'flog-2022.08.17,flog-2022.08.18' + mock_req_es.return_value = (200, '{"aggregations": {}}') + result = action.typical_stats({'log_level.keyword': 'test'}, '', + '1660722534', '1660808934') + expected = {"code": 0, "msg": "no data, no data group"} + self.assertEqual(expected, result) + if __name__ == "__main__": unittest.main()