Supplement test cases for test_generate_must.

In test_generate_must_lower, if the input is uppercase, the output
will change them to lowercase. If k is not 'keyword',
test_generate_must_other is entered.

Change-Id: I51212cb48ef7f94c09445469aa4025430e9375a3
This commit is contained in:
hejunli 2022-07-14 10:40:17 +08:00
parent e16dcbd989
commit 28635ed6f1

View File

@ -225,6 +225,18 @@ class TestSearchAction(unittest.TestCase):
expected = [{'terms': {'log_level.keyword': ['test', 'TEST']}}] expected = [{'terms': {'log_level.keyword': ['test', 'TEST']}}]
self.assertEqual(expected, result) self.assertEqual(expected, result)
def test_generate_must_lower(self):
action = SearchCore()
result = action.generate_must({'log_level.keyword': 'TEST'})
expected = [{'terms': {'log_level.keyword': ['TEST', 'test']}}]
self.assertEqual(expected, result)
def test_generate_must_other(self):
action = SearchCore()
result = action.generate_must({'key': ['value1', 'value2']})
expected = [{'match_phrase': {'key': {'query': ['value1', 'value2']}}}]
self.assertEqual(expected, result)
def test_generate_must_not(self): def test_generate_must_not(self):
action = SearchCore() action = SearchCore()
result = action.generate_must_not({'log_level.keyword': result = action.generate_must_not({'log_level.keyword':