Skip to content

Commit

Permalink
test: Remove useless common types and refine error assert in negative…
Browse files Browse the repository at this point in the history
… cases (#33023)

Related issue: #32653 

1. Remove some meaningless common types
2. Refine error assertion in negative cases
3. Remove some dup tests

---------

Signed-off-by: yanliang567 <yanliang.qiao@zilliz.com>
  • Loading branch information
yanliang567 committed May 14, 2024
1 parent 1d48d0a commit ba3b2a9
Show file tree
Hide file tree
Showing 11 changed files with 260 additions and 1,129 deletions.
59 changes: 20 additions & 39 deletions tests/python_client/common/common_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,36 +105,27 @@
rows_all_data_type_file_path = "/tmp/rows_all_data_type"

"""" List of parameters used to pass """
get_invalid_strs = [
[],
1,
[1, "2", 3],
(1,),
{1: 1},
None,
"",
" ",
"12-s",
"12 s",
"(mn)",
"中文",
"%$#",
"".join("a" for i in range(max_name_length + 1))]
invalid_resource_names = [
None, # None
" ", # space
"", # empty
"12name", # start with number
"n12 ame", # contain space
"n-ame", # contain hyphen
"nam(e)", # contain special character
"name中文", # contain Chinese character
"name%$#", # contain special character
"".join("a" for i in range(max_name_length + 1))] # exceed max length

get_invalid_type_fields = [
1,
[1, "2", 3],
(1,),
{1: 1},
None,
"",
" ",
"12-s",
"12 s",
"(mn)",
"中文",
"%$#",
"".join("a" for i in range(max_name_length + 1))]
valid_resource_names = [
"name", # valid name
"_name", # start with underline
"_12name", # start with underline and contains number
"n12ame_", # end with letter and contains number and underline
"nam_e", # contains underline
"".join("a" for i in range(max_name_length))] # max length

invalid_dims = [min_dim-1, 32.1, -32, "vii", "十六", max_dim+1]

get_not_string = [
[],
Expand All @@ -146,16 +137,6 @@
[1, "2", 3]
]

get_not_string_value = [
" ",
"12-s",
"12 s",
"(mn)",
"中文",
"%$#",
"a".join("a" for i in range(256))
]

get_invalid_vectors = [
"1*2",
[1],
Expand Down
25 changes: 0 additions & 25 deletions tests/python_client/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,31 +234,11 @@ def initialize_env(request):
param_info.prepare_param_info(host, port, handler, replica_num, user, password, secure, uri, token)


@pytest.fixture(params=ct.get_invalid_strs)
def get_invalid_string(request):
yield request.param


@pytest.fixture(params=cf.gen_simple_index())
def get_index_param(request):
yield request.param


@pytest.fixture(params=ct.get_invalid_strs)
def get_invalid_collection_name(request):
yield request.param


@pytest.fixture(params=ct.get_invalid_strs)
def get_invalid_field_name(request):
yield request.param


@pytest.fixture(params=ct.get_invalid_strs)
def get_invalid_index_type(request):
yield request.param


# TODO: construct invalid index params for all index types
@pytest.fixture(params=[{"metric_type": "L3", "index_type": "IVF_FLAT"},
{"metric_type": "L2", "index_type": "IVF_FLAT", "err_params": {"nlist": 10}},
Expand All @@ -267,11 +247,6 @@ def get_invalid_index_params(request):
yield request.param


@pytest.fixture(params=ct.get_invalid_strs)
def get_invalid_partition_name(request):
yield request.param


@pytest.fixture(params=ct.get_invalid_dict)
def get_invalid_vector_dict(request):
yield request.param
Expand Down
Loading

0 comments on commit ba3b2a9

Please sign in to comment.