From 37c331bf65a736bde7044e3f563be1ef349f5641 Mon Sep 17 00:00:00 2001 From: binbin <83755740+binbinlv@users.noreply.github.com> Date: Tue, 23 Nov 2021 15:43:17 +0800 Subject: [PATCH] Update test case for code fix (#12209) Signed-off-by: Binbin Lv --- .../python_client/testcases/test_search_20.py | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/tests/python_client/testcases/test_search_20.py b/tests/python_client/testcases/test_search_20.py index 4788893d88..6a365c4483 100644 --- a/tests/python_client/testcases/test_search_20.py +++ b/tests/python_client/testcases/test_search_20.py @@ -89,6 +89,10 @@ class TestCollectionSearchInvalid(TestcaseBase): pytest.skip("empty field is valid") yield request.param + @pytest.fixture(scope="function", params=ct.get_invalid_strs) + def get_invalid_expr_bool_value(self, request): + yield request.param + @pytest.fixture(scope="function", params=ct.get_invalid_strs) def get_invalid_partition(self, request): if request.param == []: @@ -395,6 +399,25 @@ class TestCollectionSearchInvalid(TestcaseBase): "err_msg": "invalid expression %s" % invalid_search_expr}) + @pytest.mark.tags(CaseLabel.L2) + def test_search_param_invalid_expr_bool(self, get_invalid_expr_bool_value): + """ + target: test search with invalid parameter values + method: search with invalid bool search expressions + expected: raise exception and report the error + """ + # 1. initialize with data + collection_w = self.init_collection_general(prefix, True, is_all_data_type=True)[0] + # 2 search with invalid bool expr + invalid_search_expr_bool = f"{default_bool_field_name} == {get_invalid_expr_bool_value}" + log.info("test_search_param_invalid_expr_bool: searching with " + "invalid expr: %s" % invalid_search_expr_bool) + collection_w.search(vectors[:default_nq], default_search_field, + default_search_params, default_limit, invalid_search_expr_bool, + check_task=CheckTasks.err_res, + check_items={"err_code": 1, + "err_msg": "failed to create query plan"}) + @pytest.mark.tags(CaseLabel.L2) def test_search_partition_invalid_type(self, get_invalid_partition): """ @@ -1805,8 +1828,7 @@ class TestCollectionSearch(TestcaseBase): assert set(ids).issubset(filter_ids_set) @pytest.mark.tags(CaseLabel.L2) - @pytest.mark.xfail(reason="issue 7910") - @pytest.mark.parametrize("bool_type", [True, False, "true", "false", 1, 0, 2]) + @pytest.mark.parametrize("bool_type", [True, False, "true", "false"]) def test_search_with_expression_bool(self, dim, auto_id, _async, bool_type): """ target: test search with different bool expressions