Skip to content
Merged
25 changes: 14 additions & 11 deletions python/tests/detail/params_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
for param in params
]

COLLECTION_NAME_MAX_LENGTH = 64
COLLECTION_NAME_MAX_LENGTH = 256

COLLECTION_NAME_VALID_LIST = [
"col",
Expand All @@ -148,17 +148,20 @@
"collection_2",
"123collection-",
"a" * COLLECTION_NAME_MAX_LENGTH,
]

COLLECTION_NAME_INVALID_LIST = [
"l",
"1C",
"",
" ",
None,
"abcdefghijklmnopqrstuvwxzy123456abcdefghijklmnopqrstuvwxzy1234561",
"test/",
"!@#$%^&*()test",
"集合名称",
]

COLLECTION_NAME_INVALID_LIST = [
"",
None,
"a" * (COLLECTION_NAME_MAX_LENGTH + 1),
"collection\0name",
"collection\nname",
]

FIELD_NAME_VALID_LIST = [
Expand All @@ -178,7 +181,7 @@
"",
" ",
None,
"abcdefghijklmnopqrstuvwxzy1234561",
"a" * 65,
"test/",
"!@#$%^&*()test",
"name@with#special$chars",
Expand Down Expand Up @@ -208,12 +211,12 @@


INCOMPATIBLE_CONSTRUCTOR_ERROR_MSG = "incompatible constructor arguments"
SCHEMA_VALIDATE_ERROR_MSG = "schema validate failed"
SCHEMA_VALIDATE_ERROR_MSG = "Invalid schema"
CREATE_READ_ONLY_ERROR_MSG = "Unable to create collection with read-only mode"
INCOMPATIBLE_FUNCTION_ERROR_MSG = "incompatible function arguments"
INVALID_PATH_ERROR_MSG = "path validate failed"
INDEX_NON_EXISTENT_COLUMN_ERROR_MSG = "not found in schema"
ACCESS_DESTROYED_COLLECTION_ERROR_MSG = "is already destroyed"
COLLECTION_PATH_NOT_EXIST_ERROR_MSG = "not exist"
NOT_SUPPORT_ADD_COLUMN_ERROR_MSG = "Only support basic numeric data type"
NOT_EXIST_COLUMN_TO_DROP_ERROR_MSG = "Column not exists"
NOT_SUPPORT_ADD_COLUMN_ERROR_MSG = "this operation requires a numeric field"
NOT_EXIST_COLUMN_TO_DROP_ERROR_MSG = "field.*not found"
23 changes: 11 additions & 12 deletions python/tests/detail/test_collection_ddl.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ def check_error_message(exc_info, invalid_name):
[
("", ""), # Empty string
(" ", " "), # Space only
("v" * 33, "v" * 33), # Too long (33 characters, exceeds 32)
("v" * 33, "v" * 33), # Field does not exist.
("vector name", "vector_name"), # Contains space
("vector@name", "vector@name"), # Contains special character
("vector/name", "vector/name"), # Contains slash
Expand Down Expand Up @@ -1202,7 +1202,7 @@ def test_add_column_with_index_param(self, basic_collection: Collection):
"field_name",
[
"a", # Minimum length
"a" * 32, # Maximum length (32 characters)
"a" * 64, # Maximum field name length.
"valid_field_name_123", # Alphanumeric with underscore
"Valid-Field-Name", # With hyphens
"_underscore_start", # Starting with underscore
Expand Down Expand Up @@ -1241,7 +1241,7 @@ def test_add_column_with_valid_field_names(
[
"", # Empty string
" ", # Space only
"a" * 33, # Too long (33 characters, exceeds 32)
"a" * 65, # Exceeds the field name byte limit.
"field name", # Contains space
"field.name", # Contains dot
"field@name", # Contains special character
Expand All @@ -1263,7 +1263,7 @@ def test_add_column_with_invalid_field_names(
)

if invalid_field_name is None:
assert "validate failed" in str(exc_info.value), (
assert "Invalid schema:" in str(exc_info.value), (
"Error message is unreasonable: e=" + str(exc_info.value)
)
else:
Expand Down Expand Up @@ -1303,7 +1303,7 @@ def test_alter_column_non_exist(self, basic_collection: Collection):
new_name="new_name",
field_schema=FieldSchema("new_name", DataType.STRING),
)
assert "column non_existing not found" in str(exc_info.value), (
assert "Invalid schema: field[non_existing] not found" in str(exc_info.value), (
"Error message is unreasonable: e=" + str(exc_info.value)
)

Expand Down Expand Up @@ -1378,9 +1378,9 @@ def test_alter_column_with_various_concurrency_options(
[
("a", "new_a"), # Minimum length
(
"abcdefghijklmnopqrstuvwxyz123456",
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
), # Maximum length (32 characters)
"a" * 64,
"b" * 64,
), # Maximum field name length.
("valid_field_name_123", "new_valid_field"), # Alphanumeric with underscore
("Valid-Field-Name", "New-Field-Name"), # With hyphens
("_underscore_start", "new_underscore"), # Starting with underscore
Expand Down Expand Up @@ -1427,7 +1427,7 @@ def test_alter_column_field_name_valid(
"valid_old_name,invalid_new_name",
[
("temp_field", ""), # Empty new name
("temp_field", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), # Too long new name
("temp_field", "a" * 65), # Exceeds the field name byte limit.
("temp_field", "field name"), # New name with space
("temp_field", "field.name"), # New name with dot
("temp_field", "field@name"), # New name with special character
Expand Down Expand Up @@ -1499,15 +1499,14 @@ def test_drop_column_exist(self, basic_collection: Collection):
assert SCHEMA_VALIDATE_ERROR_MSG in str(exc_info.value)

def test_drop_column_non_exist(self, basic_collection: Collection):
with pytest.raises(Exception) as exc_info:
with pytest.raises(Exception, match=NOT_EXIST_COLUMN_TO_DROP_ERROR_MSG):
basic_collection.drop_column("non_existing_column")
assert NOT_EXIST_COLUMN_TO_DROP_ERROR_MSG in str(exc_info.value)

@pytest.mark.parametrize(
"field_name",
[
"a", # Minimum length
"a" * 32, # Maximum length (32 characters)
"a" * 64, # Maximum field name length.
"valid_field_name_123", # Alphanumeric with underscore
"Valid-Field-Name", # With hyphens
"_underscore_start", # Starting with underscore
Expand Down
12 changes: 8 additions & 4 deletions python/tests/detail/test_collection_dml.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,18 @@
"123abc",
"-!@#$%+=.123abc_+",
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ123456789012",
"()qsd123",
" ",
"/&AS12",
"订单:2026",
"a" * 1024,
]
DOCID_INVALID_LIST = [
None,
"",
"()qsd123",
" ",
"/&AS12",
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890121",
"a" * 1025,
"doc\0id",
"doc\nid",
]

FIELD_VALUE_VALID_LIST = [
Expand Down
Loading
Loading