about summary refs log tree commit diff
path: root/tests/qc/test_cells.py
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2023-11-24 14:44:50 +0300
committerFrederick Muriuki Muriithi2023-11-24 14:44:50 +0300
commitc213b0010c3ddc8d3215adab65bd489a9b884e30 (patch)
treedd8de4cf1e28dd5ed88d17f25f52c79c3d56237e /tests/qc/test_cells.py
parent2bf17b88bca366f9ced851a6152e034f8e94f7ac (diff)
downloadgn-uploader-c213b0010c3ddc8d3215adab65bd489a9b884e30.tar.gz
QC: Check for only one decimal place.
Diffstat (limited to 'tests/qc/test_cells.py')
-rw-r--r--tests/qc/test_cells.py21
1 files changed, 13 insertions, 8 deletions
diff --git a/tests/qc/test_cells.py b/tests/qc/test_cells.py
index 1c6c3f6..f5411fe 100644
--- a/tests/qc/test_cells.py
+++ b/tests/qc/test_cells.py
@@ -1,7 +1,8 @@
 """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
 
@@ -10,7 +11,7 @@ from quality_control.average import invalid_value as avg_invalid_value
 from quality_control.standard_error import invalid_value as se_invalid_value
 
 @given(num_str=st.from_regex(
-    r"^(?!(([0-9]+\.([0-9]{3}|[0-9]{6,}))|[0-9]+\.?0*)).*", fullmatch=True))
+    r"^(?!([0-9]+\.[0-9]{1,}|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,
@@ -22,12 +23,14 @@ 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 exactly three decimal places."))
+            "with at least one decimal place."))
     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 six decimal places."))
+            "with at least one decimal place."))
 
+@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)))
@@ -45,10 +48,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."))
 
-@given(num_str=st.from_regex(r"^[0-9]+\.[0-9]{3}$", fullmatch=True))
+@given(num_str=st.from_regex(r"^[0-9]+\.[0-9]{1,}$", fullmatch=True))
 def test_cell_average_value_pass_if_three_decimal_places(num_str):
     """
-    GIVEN: `num_str` is a string representing a number with exactly three
+    GIVEN: `num_str` is a string representing a number with at least one
       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`
@@ -56,6 +59,8 @@ 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):
@@ -73,10 +78,10 @@ def test_cell_standard_error_value_errors_if_less_than_six_decimal_places2(num_s
             "with at least six decimal places."))
 
 
-@given(num_str=st.from_regex(r"^[0-9]+\.[0-9]{6,}$", fullmatch=True))
+@given(num_str=st.from_regex(r"^[0-9]+\.[0-9]{1,}$", 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 six or more
+    GIVEN: `num_str` is a string representing a number with one 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`