-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for classification utilities.
- Loading branch information
1 parent
dcc36c3
commit dec4db8
Showing
1 changed file
with
69 additions
and
0 deletions.
There are no files selected for viewing
69 changes: 69 additions & 0 deletions
69
archeryutils/classifications/tests/test_classification_utils.py
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,69 @@ | ||
"""Tests for classification utilities""" | ||
import pytest | ||
|
||
import archeryutils.classifications.classification_utils as class_utils | ||
|
||
|
||
class TestStringUtils: | ||
""" | ||
Class to test the get_groupname() function of handicap_equations. | ||
Methods | ||
------- | ||
test_get_groupname() | ||
test if expected sanitised groupname returned | ||
test_strip_spots() | ||
test if expected full-face roundname returned | ||
""" | ||
|
||
@pytest.mark.parametrize( | ||
"bowstyle,age_group,gender,groupname_expected", | ||
# Check all systems, different distances, negative and large handicaps. | ||
[ | ||
("barebow", "adult", "male", "adult_male_barebow"), | ||
("Barebow", "Adult", "Male", "adult_male_barebow"), | ||
("Barebow", "Under 18", "Male", "under18_male_barebow"), | ||
("RECURVE", "UnDeR 18", "femaLe", "under18_female_recurve"), | ||
], | ||
) | ||
def test_get_groupname( | ||
self, | ||
age_group: str, | ||
gender: str, | ||
bowstyle: str, | ||
groupname_expected: str, | ||
) -> None: | ||
""" | ||
Check that get_groupname(handicap=float) returns expected value for a case. | ||
""" | ||
groupname = class_utils.get_groupname( | ||
bowstyle=bowstyle, | ||
gender=gender, | ||
age_group=age_group, | ||
) | ||
|
||
assert groupname == groupname_expected | ||
|
||
@pytest.mark.parametrize( | ||
"roundname,strippedname_expected", | ||
# Check all systems, different distances, negative and large handicaps. | ||
[ | ||
("portsmouth", "portsmouth"), | ||
("portsmouth_triple", "portsmouth"), | ||
("portsmouth_compound", "portsmouth_compound"), | ||
("portsmouth_compound_triple", "portsmouth_compound"), | ||
("portsmouth_triple_compound", "portsmouth_compound"), | ||
("worcester_5_centre", "worcester"), | ||
], | ||
) | ||
def test_strip_spots( | ||
self, | ||
roundname: str, | ||
strippedname_expected: str, | ||
) -> None: | ||
""" | ||
Check that strip_spots() returns expected value for a round. | ||
""" | ||
strippedname = class_utils.strip_spots(roundname) | ||
|
||
assert strippedname == strippedname_expected |