Model/etl/epc_clean/tests/test_utils.py
Khalim Conn-Kowlessar 965e8e99d3 fixed unit tests
2023-10-05 16:04:12 +01:00

21 lines
1 KiB
Python

from etl.epc_clean.utils import is_percentage_or_number, correct_spelling
class TestUtils:
def test_is_percentage_or_number(self):
assert is_percentage_or_number("88")
assert is_percentage_or_number("88%")
assert not is_percentage_or_number("abc")
assert not is_percentage_or_number("")
assert not is_percentage_or_number("88.0") # only integer numbers or percentages
assert is_percentage_or_number("101%") # numbers over 100 allowed
assert not is_percentage_or_number("-1") # negative numbers not allowed
def test_correct_spelling(self):
assert correct_spelling("speling") == "spelling"
assert correct_spelling("88") == "88" # numbers are left unchanged
assert correct_spelling("corerct") == "correct"
assert correct_spelling("excllent") == "excellent"
assert correct_spelling("") == "" # empty string should return an empty string
assert correct_spelling("88%") == "88%" # percentages are left unchanged