Skip to content

Commit

Permalink
Add tests for classification utilities.
Browse files Browse the repository at this point in the history
  • Loading branch information
jatkinson1000 committed Aug 24, 2023
1 parent dcc36c3 commit dec4db8
Showing 1 changed file with 69 additions and 0 deletions.
69 changes: 69 additions & 0 deletions archeryutils/classifications/tests/test_classification_utils.py
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

0 comments on commit dec4db8

Please sign in to comment.