-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f5b77d7
commit 75edcbc
Showing
3 changed files
with
130 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import pytest | ||
from pyworkforce.shifts.utils import check_positive_integer, check_positive_float | ||
|
||
|
||
def test_check_positive_integer(): | ||
assert check_positive_integer('my_val', 5) | ||
|
||
|
||
def test_check_non_positive_integers(): | ||
with pytest.raises(Exception) as excinfo: | ||
result = check_positive_integer('my_val', -1) | ||
assert str(excinfo.value) == "my_val must be a positive integer" | ||
|
||
with pytest.raises(Exception) as excinfo: | ||
result = check_positive_integer('my_val2', 5.4) | ||
assert str(excinfo.value) == "my_val2 must be a positive integer" | ||
|
||
|
||
def test_check_positive_float(): | ||
assert check_positive_float('my_val', 2.43) | ||
|
||
|
||
def test_check_non_positive_floats(): | ||
with pytest.raises(Exception) as excinfo: | ||
result = check_positive_float('my_val', -45.3) | ||
assert str(excinfo.value) == "my_val must be a positive float" | ||
|
||
with pytest.raises(Exception) as excinfo: | ||
result = check_positive_float('my_val2', 80) | ||
assert str(excinfo.value) == "my_val2 must be a positive float" |