-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chg ! optimize find duplicates, tests
- Loading branch information
1 parent
09adab6
commit d594a93
Showing
5 changed files
with
95 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
from typing import Final | ||
from typing import Dict, Final | ||
|
||
FILENAME: Final[str] = "test_file.jpg" | ||
FILENAMES: Final[list[str]] = ["test_file.jpg", "test_file2.jpg"] | ||
DEPLOY_PROTO_SHAPE: Final[Dict[str, int]] = {"batch_size": 1, "channels": 3, "height": 300, "width": 300} |
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,41 @@ | ||
from django.forms import ValidationError | ||
|
||
import pytest | ||
|
||
from hope_dedup_engine.apps.faces.validators import MeanValuesTupleField | ||
|
||
|
||
def test_to_python_valid_tuple(): | ||
field = MeanValuesTupleField() | ||
assert field.to_python("104.0, 177.0, 123.0") == (104.0, 177.0, 123.0) | ||
|
||
|
||
def test_to_python_invalid_length(): | ||
field = MeanValuesTupleField() | ||
with pytest.raises(ValidationError) as exc_info: | ||
field.to_python("104.0, 177.0") | ||
assert "Enter a valid tuple of three float values separated by commas and spaces" in str(exc_info.value) | ||
|
||
|
||
def test_to_python_value_out_of_range(): | ||
field = MeanValuesTupleField() | ||
with pytest.raises(ValidationError) as exc_info: | ||
field.to_python("104.0, 177.0, 256.0") | ||
assert "Each value must be between -255 and 255." in str(exc_info.value) | ||
|
||
|
||
def test_to_python_non_numeric_value(): | ||
field = MeanValuesTupleField() | ||
with pytest.raises(ValidationError) as exc_info: | ||
field.to_python("104.0, abc, 123.0") | ||
assert "Enter a valid tuple of three float values separated by commas and spaces" in str(exc_info.value) | ||
|
||
|
||
def test_prepare_value_with_tuple(): | ||
field = MeanValuesTupleField() | ||
assert field.prepare_value((104.0, 177.0, 123.0)) == "104.0, 177.0, 123.0" | ||
|
||
|
||
def test_prepare_value_with_string(): | ||
field = MeanValuesTupleField() | ||
assert field.prepare_value("104.0, 177.0, 123.0") == "104.0, 177.0, 123.0" |