Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
milvus
milvus
提交
94aced64
M
milvus
项目概览
milvus
/
milvus
大约 1 年 前同步成功
通知
261
Star
22476
Fork
2472
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
milvus
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
94aced64
编写于
5月 09, 2022
作者:
J
jingkl
提交者:
GitHub
5月 09, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[test]Add the string testcase of insert (#16847)
Signed-off-by:
N
jingkl
<
jingjing.jia@zilliz.com
>
上级
8945b80a
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
126 addition
and
1 deletion
+126
-1
tests/python_client/testcases/test_insert.py
tests/python_client/testcases/test_insert.py
+126
-1
未找到文件。
tests/python_client/testcases/test_insert.py
浏览文件 @
94aced64
...
...
@@ -1094,5 +1094,130 @@ class TestInsertInvalidBinary(TestcaseBase):
error
=
{
ct
.
err_code
:
1
,
'err_msg'
:
"The types of schema and data do not match."
}
mutation_res
,
_
=
collection_w
.
insert
(
data
=
df
,
partition_name
=
partition_name
,
check_task
=
CheckTasks
.
err_res
,
check_items
=
error
)
class
TestInsertString
(
TestcaseBase
):
"""
******************************************************************
The following cases are used to test insert string
******************************************************************
"""
@
pytest
.
mark
.
tags
(
CaseLabel
.
L0
)
def
test_insert_string_field_is_primary
(
self
):
"""
target: test insert string is primary
method: 1.create a collection and string field is primary
2.insert string field data
expected: Insert Successfully
"""
c_name
=
cf
.
gen_unique_str
(
prefix
)
schema
=
cf
.
gen_string_pk_default_collection_schema
()
collection_w
=
self
.
init_collection_wrap
(
name
=
c_name
,
schema
=
schema
)
data
=
cf
.
gen_default_list_data
(
ct
.
default_nb
)
mutation_res
,
_
=
collection_w
.
insert
(
data
=
data
)
assert
mutation_res
.
insert_count
==
ct
.
default_nb
assert
mutation_res
.
primary_keys
==
data
[
2
]
@
pytest
.
mark
.
tags
(
CaseLabel
.
L0
)
@
pytest
.
mark
.
parametrize
(
"string_fields"
,
[[
cf
.
gen_string_field
(
name
=
"string_field1"
)],
[
cf
.
gen_string_field
(
name
=
"string_field2"
)],
[
cf
.
gen_string_field
(
name
=
"string_field3"
)]])
def
test_insert_multi_string_fields
(
self
,
string_fields
):
"""
target: test insert multi string fields
method: 1.create a collection
2.Insert multi string fields
expected: Insert Successfully
"""
schema
=
cf
.
gen_schema_multi_string_fields
(
string_fields
)
collection_w
=
self
.
init_collection_wrap
(
name
=
cf
.
gen_unique_str
(
prefix
),
schema
=
schema
)
df
=
cf
.
gen_dataframe_multi_string_fields
(
string_fields
=
string_fields
)
collection_w
.
insert
(
df
)
assert
collection_w
.
num_entities
==
ct
.
default_nb
@
pytest
.
mark
.
tags
(
CaseLabel
.
L0
)
def
test_insert_string_field_invalid_data
(
self
):
"""
target: test insert string field data is not match
method: 1.create a collection
2.Insert string field data is not match
expected: Raise exceptions
"""
c_name
=
cf
.
gen_unique_str
(
prefix
)
collection_w
=
self
.
init_collection_wrap
(
name
=
c_name
)
nb
=
10
df
=
cf
.
gen_default_dataframe_data
(
nb
)
new_float_value
=
pd
.
Series
(
data
=
[
float
(
i
)
for
i
in
range
(
nb
)],
dtype
=
"float64"
)
df
.
iloc
[:,
2
]
=
new_float_value
error
=
{
ct
.
err_code
:
0
,
ct
.
err_msg
:
'The types of schema and data do not match'
}
collection_w
.
insert
(
data
=
df
,
check_task
=
CheckTasks
.
err_res
,
check_items
=
error
)
@
pytest
.
mark
.
tags
(
CaseLabel
.
L0
)
def
test_insert_string_field_name_invalid
(
self
):
"""
target: test insert string field name is invaild
method: 1.create a collection
2.Insert string field name is invalid
expected: Raise exceptions
"""
c_name
=
cf
.
gen_unique_str
(
prefix
)
collection_w
=
self
.
init_collection_wrap
(
name
=
c_name
)
df
=
[
cf
.
gen_int64_field
(),
cf
.
gen_string_field
(
name
=
ct
.
get_invalid_strs
),
cf
.
gen_float_vec_field
()]
error
=
{
ct
.
err_code
:
0
,
ct
.
err_msg
:
'Data type is not support.'
}
collection_w
.
insert
(
data
=
df
,
check_task
=
CheckTasks
.
err_res
,
check_items
=
error
)
@
pytest
.
mark
.
tags
(
CaseLabel
.
L0
)
def
test_insert_string_field_length_exceed
(
self
):
"""
target: test insert string field exceed the maximum length
method: 1.create a collection
2.Insert string field length is exceeded maximum value of 65535
expected: Raise exceptions
"""
c_name
=
cf
.
gen_unique_str
(
prefix
)
collection_w
=
self
.
init_collection_wrap
(
name
=
c_name
)
nums
=
70000
field_one
=
cf
.
gen_int64_field
()
field_two
=
cf
.
gen_float_field
()
field_three
=
cf
.
gen_string_field
(
max_length_per_row
=
nums
)
vec_field
=
cf
.
gen_float_vec_field
()
df
=
[
field_one
,
field_two
,
field_three
,
vec_field
]
error
=
{
ct
.
err_code
:
0
,
ct
.
err_msg
:
'Data type is not support.'
}
collection_w
.
insert
(
data
=
df
,
check_task
=
CheckTasks
.
err_res
,
check_items
=
error
)
@
pytest
.
mark
.
tags
(
CaseLabel
.
L1
)
def
test_insert_string_field_dtype_invalid
(
self
):
"""
target: test insert string field with invaild dtype
method: 1.create a collection
2.Insert string field dtype is invalid
expected: Raise exception
"""
c_name
=
cf
.
gen_unique_str
(
prefix
)
collection_w
=
self
.
init_collection_wrap
(
name
=
c_name
)
string_field
=
self
.
field_schema_wrap
.
init_field_schema
(
name
=
"string"
,
dtype
=
DataType
.
STRING
)[
0
]
int_field
=
cf
.
gen_int64_field
(
is_primary
=
True
)
vec_field
=
cf
.
gen_float_vec_field
()
df
=
[
string_field
,
int_field
,
vec_field
]
error
=
{
ct
.
err_code
:
0
,
ct
.
err_msg
:
'Data type is not support.'
}
collection_w
.
insert
(
data
=
df
,
check_task
=
CheckTasks
.
err_res
,
check_items
=
error
)
@
pytest
.
mark
.
tags
(
CaseLabel
.
L1
)
def
test_insert_string_field_auto_id_is_true
(
self
):
"""
target: test create collection with string field
method: 1.create a collection
2.Insert string field with auto id is true
expected: Raise exception
"""
c_name
=
cf
.
gen_unique_str
(
prefix
)
collection_w
=
self
.
init_collection_wrap
(
name
=
c_name
)
int_field
=
cf
.
gen_int64_field
()
vec_field
=
cf
.
gen_float_vec_field
()
string_field
=
cf
.
gen_string_field
(
is_primary
=
True
,
auto_id
=
True
)
df
=
[
int_field
,
string_field
,
vec_field
]
error
=
{
ct
.
err_code
:
0
,
ct
.
err_msg
:
'Data type is not support.'
}
collection_w
.
insert
(
data
=
df
,
check_task
=
CheckTasks
.
err_res
,
check_items
=
error
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录