-
Notifications
You must be signed in to change notification settings - Fork 339
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: yangxuan <[email protected]>
- Loading branch information
1 parent
49c79bd
commit 51fb7c1
Showing
7 changed files
with
193 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import pytest | ||
from pymilvus.utils import TypeChecker | ||
from pymilvus.exceptions import ParamError | ||
|
||
|
||
class TestTypeChecker: | ||
@pytest.mark.parametrize("type_str", [ | ||
"s", | ||
"_", | ||
]) | ||
def test_str_type(self, type_str): | ||
TypeChecker.check( | ||
collection_name=type_str, | ||
alias=type_str, | ||
name=type_str, | ||
partition_name=type_str, | ||
index_name=type_str, | ||
field_name=type_str, | ||
anns_field=type_str, | ||
) | ||
|
||
@pytest.mark.parametrize("not_type_str", [ | ||
None, | ||
1, | ||
1.0, | ||
[1], | ||
{1: 2}, | ||
{1, 2, 3}, | ||
(1, 2, 3), | ||
]) | ||
def test_str_type_error(self, not_type_str): | ||
with pytest.raises(ParamError): | ||
TypeChecker.check(collection_name=not_type_str) | ||
|
||
@pytest.mark.parametrize("type_int", [ | ||
1, | ||
0, | ||
-1, | ||
1024, | ||
65536, | ||
]) | ||
def test_int_type(self, type_int): | ||
TypeChecker.check( | ||
round_decimal=type_int, | ||
num_replica=type_int, | ||
dim=type_int, | ||
limit=type_int, | ||
topk=type_int, | ||
) | ||
|
||
@pytest.mark.parametrize("not_type_int", [ | ||
None, | ||
"abc", | ||
1.0, | ||
[1], | ||
{1: 2}, | ||
{1, 2, 3}, | ||
(1, 2, 3), | ||
]) | ||
def test_int_type_error(self, not_type_int): | ||
with pytest.raises(ParamError): | ||
TypeChecker.check(topk=not_type_int) | ||
|
||
@pytest.mark.parametrize("type_list_str", [ | ||
["a"], | ||
["1", "2"] | ||
]) | ||
def test_list_str_type(self, type_list_str): | ||
TypeChecker.check( | ||
partition_names=type_list_str, | ||
output_fields=type_list_str, | ||
) | ||
|
||
@pytest.mark.parametrize("not_type_list_str", [ | ||
None, | ||
"abc", | ||
1.0, | ||
{1: 2}, | ||
{1, 2, 3}, | ||
(1, 2, 3), | ||
[1], | ||
[], | ||
[1, "1"], | ||
]) | ||
def test_int_type_error(self, not_type_list_str): | ||
with pytest.raises(ParamError): | ||
TypeChecker.check(topk=not_type_list_str) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters