-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Motion detection threshold accepts floating point input. * First crack at client-side cropping. * Fixing a couple bugs. Client-side crop is working now. * Automatically reformatting code with black and isort --------- Co-authored-by: Auto-format Bot <[email protected]>
- Loading branch information
1 parent
0850213
commit 05664b1
Showing
2 changed files
with
87 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import pytest | ||
|
||
from stream import parse_crop_string | ||
|
||
|
||
def test_good_crop(): | ||
assert parse_crop_string("0,0,1,1") == (0, 0, 1, 1) | ||
assert parse_crop_string("0.5,0,0.5,1") == (0.5, 0, 0.5, 1) | ||
|
||
with pytest.raises(ValueError): | ||
# too short | ||
parse_crop_string("0.5,0,0.5") | ||
|
||
with pytest.raises(ValueError): | ||
# not numbers | ||
parse_crop_string("a,b,c,d") | ||
|
||
with pytest.raises(ValueError): | ||
# too big | ||
parse_crop_string("0,0,256,250") | ||
|
||
with pytest.raises(ValueError): | ||
# negative | ||
parse_crop_string("-1,0,1,1") | ||
|
||
with pytest.raises(ValueError): | ||
# Off both edges | ||
parse_crop_string("0.5,0.5,0.6,0.6") | ||
|
||
with pytest.raises(ValueError): | ||
# Off right | ||
parse_crop_string("0.3,0,0.8,1") | ||
|
||
with pytest.raises(ValueError): | ||
# Off bottom | ||
parse_crop_string("0,0.2,0.5,0.9") | ||
|
||
with pytest.raises(ValueError): | ||
# zero size | ||
parse_crop_string("0,0,1,0") |