-
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.
- Loading branch information
Showing
1 changed file
with
55 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
"""Test the enum.Sex enum.""" | ||
|
||
import pytest | ||
from geneweaver.core.enum import Sex | ||
|
||
|
||
def test_sex_enum_as_string(): | ||
"""Test that the Sex enum renders to string as expected.""" | ||
|
||
assert str(Sex.FEMALE) == "Female" | ||
assert str(Sex.MALE) == "Male" | ||
assert str(Sex.BOTH) == "Both" | ||
|
||
|
||
def test_initialize_sex_enum_from_string(): | ||
"""Test that we can initialize the Sex enum as expected.""" | ||
|
||
assert Sex("Female") == Sex.FEMALE | ||
assert Sex("Male") == Sex.MALE | ||
assert Sex("Both") == Sex.BOTH | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"invalid_sex_value", | ||
[ | ||
"test", | ||
"another", | ||
"CAPS", | ||
"MALE", | ||
"male", | ||
"FEMALE", | ||
"female", | ||
"BOTH", | ||
"both", | ||
"neither", | ||
"either", | ||
"none", | ||
"all", | ||
"unknown", | ||
"other", | ||
"12345", | ||
"1.2345", | ||
"0", | ||
"None", | ||
], | ||
) | ||
def test_sex_enum_raises_error_when_initialized_with_invalid_value(invalid_sex_value): | ||
"""Test that initializing the Sex enum with an invalid value raises an error.""" | ||
|
||
with pytest.raises(ValueError) as error_info: | ||
Sex(invalid_sex_value) | ||
|
||
assert ( | ||
str(error_info.value) == f"'{invalid_sex_value}' is not a valid Sex" | ||
) |