aboutsummaryrefslogtreecommitdiff
path: root/tests/qc
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-01-05 07:35:04 +0300
committerFrederick Muriuki Muriithi2024-01-05 07:35:04 +0300
commit65c9f923a5057c99c18f43e2c1f0284d8293d9a3 (patch)
treedf89b2f06cf14c7e161598477c22f055576a7848 /tests/qc
parent5f5cc8503ec10319ee4d9e7d6bd739cc6190561c (diff)
downloadgn-uploader-65c9f923a5057c99c18f43e2c1f0284d8293d9a3.tar.gz
Revert "QC: Check for only one decimal place."
This reverts commit c213b0010c3ddc8d3215adab65bd489a9b884e30. After a larger discussion with Arthur, Rob and Pjotr present, it was verified that the strict checks are important. This reverts the commit that allowed for looser checks.
Diffstat (limited to 'tests/qc')
-rw-r--r--tests/qc/test_cells.py23
-rw-r--r--tests/qc/test_cells_average.py4
-rw-r--r--tests/qc/test_cells_standard_error.py4
3 files changed, 9 insertions, 22 deletions
diff --git a/tests/qc/test_cells.py b/tests/qc/test_cells.py
index 51e8bcf..2bb3358 100644
--- a/tests/qc/test_cells.py
+++ b/tests/qc/test_cells.py
@@ -1,8 +1,7 @@
"""Test that values in cells within a line fulfill the required criteria"""
+
import re
from random import randint
-
-import pytest
from hypothesis import given
from hypothesis import strategies as st
@@ -12,7 +11,7 @@ from quality_control.standard_error import invalid_value as se_invalid_value
@pytest.mark.unit_test
@given(num_str=st.from_regex(
- r"^(?!([0-9]+\.[0-9]{1,}|0+)).*", fullmatch=True))
+ r"^(?!(([0-9]+\.([0-9]{3}|[0-9]{6,}))|[0-9]+\.?0*)).*", fullmatch=True))
def test_cell_value_errors_with_invalid_inputs2(num_str):
"""
GIVEN: `num_str` is an arbitrary string that is an invalid input,
@@ -24,14 +23,12 @@ def test_cell_value_errors_with_invalid_inputs2(num_str):
assert avg_invalid_value(0, 0, num_str) == InvalidValue(
0, 0, num_str, (
f"Invalid value '{num_str}'. Expected string representing a number "
- "with at least one decimal place."))
+ "with exactly three decimal places."))
assert se_invalid_value(0, 0, num_str) == InvalidValue(
0, 0, num_str, (
f"Invalid value '{num_str}'. Expected string representing a number "
- "with at least one decimal place."))
+ "with at least six decimal places."))
-@pytest.mark.skip(reason=("Checks changed. We now enforce values must have at "
- "least one decimal place"))
@given(num_str=st.from_regex(
r"^[0-9]+\.([0-9]{1,2}|[0-9]{4,}$)", fullmatch=True).filter(
lambda param: not re.match(r"^[0-9]+\.0+$", param)))
@@ -49,11 +46,10 @@ def test_cell_average_value_errors_if_not_three_decimal_places2(num_str):
f"Invalid value '{num_str}'. Expected string representing a number "
"with exactly three decimal places."))
-@pytest.mark.unit_test
-@given(num_str=st.from_regex(r"^[0-9]+\.[0-9]{1,}$", fullmatch=True))
+@given(num_str=st.from_regex(r"^[0-9]+\.[0-9]{3}$", fullmatch=True))
def test_cell_average_value_pass_if_three_decimal_places(num_str):
"""
- GIVEN: `num_str` is a string representing a number with at least one
+ GIVEN: `num_str` is a string representing a number with exactly three
decimal places, e.g. 2.924, 39.483
WHEN: `num_str` is provided as an argument to `avg_invalid_value` function,
THEN: `avg_invalid_value` returns `None`
@@ -61,8 +57,6 @@ def test_cell_average_value_pass_if_three_decimal_places(num_str):
line, col = randint(0, 100), randint(0, 20)
assert avg_invalid_value(line, col, num_str) is None
-@pytest.mark.skip(reason=("Checks changed. We now enforce values must have at "
- "least one decimal place"))
@given(num_str=st.from_regex(r"^[0-9]+\.([0-9]{0,5}$)", fullmatch=True).filter(
lambda param: not re.match(r"^[0-9]+\.?0*$", param)))
def test_cell_standard_error_value_errors_if_less_than_six_decimal_places2(num_str):
@@ -79,11 +73,10 @@ def test_cell_standard_error_value_errors_if_less_than_six_decimal_places2(num_s
f"Invalid value '{num_str}'. Expected string representing a number "
"with at least six decimal places."))
-@pytest.mark.unit_test
-@given(num_str=st.from_regex(r"^[0-9]+\.[0-9]{1,}$", fullmatch=True))
+@given(num_str=st.from_regex(r"^[0-9]+\.[0-9]{6,}$", fullmatch=True))
def test_cell_standard_error_value_pass_if_six_or_more_decimal_places(num_str):
"""
- GIVEN: `num_str` is a string representing a number with one or more
+ GIVEN: `num_str` is a string representing a number with six or more
decimal places, e.g. 2.938434, 39.4837343
WHEN: `num_str` is provided as an argument to `se_invalid_value` function,
THEN: `se_invalid_value` returns `None`
diff --git a/tests/qc/test_cells_average.py b/tests/qc/test_cells_average.py
index cf23e13..68fd4ec 100644
--- a/tests/qc/test_cells_average.py
+++ b/tests/qc/test_cells_average.py
@@ -1,14 +1,10 @@
"""Test average values."""
from random import randint
-
-import pytest
from hypothesis import given
from hypothesis import strategies as st
from quality_control.average import invalid_value as avg_invalid_value
-@pytest.mark.skip(reason=("Checks changed. We now enforce values must have at "
- "least one decimal place"))
@given(num_str=st.from_regex(r"^[0-9]+$", fullmatch=True))
def test_cell_average_value_pass_if_no_decimal_places(num_str):
"""
diff --git a/tests/qc/test_cells_standard_error.py b/tests/qc/test_cells_standard_error.py
index 754db22..90c13cf 100644
--- a/tests/qc/test_cells_standard_error.py
+++ b/tests/qc/test_cells_standard_error.py
@@ -1,14 +1,12 @@
"""Test standard error values."""
from random import randint
-import pytest
+
from hypothesis import given
from hypothesis import strategies as st
from quality_control.standard_error import invalid_value
-@pytest.mark.skip(reason=("Checks changed. We now enforce values must have at "
- "least one decimal place"))
@given(num_str=st.from_regex(r"^[0-9]+\.?0*", fullmatch=True))
def test_cell_standard_error_value_errors_if_less_than_six_decimal_places2(num_str):
"""