diff options
author | Frederick Muriuki Muriithi | 2022-06-10 08:05:34 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2022-06-10 08:05:34 +0300 |
commit | 35a9cf67a9e055925f11a12c9fb964e5dbeb5525 (patch) | |
tree | 6c21bd33eb268cab0b931c89b1162578a6085b16 /tests | |
parent | 2f84b2eb1fecab4c381ad2dfd31277717cc9df2d (diff) | |
download | gn-uploader-35a9cf67a9e055925f11a12c9fb964e5dbeb5525.tar.gz |
Update tests: Accept zeroes as valid values
Diffstat (limited to 'tests')
-rw-r--r-- | tests/qc/test_cells.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/tests/qc/test_cells.py b/tests/qc/test_cells.py index a38be30..5ff5813 100644 --- a/tests/qc/test_cells.py +++ b/tests/qc/test_cells.py @@ -1,5 +1,6 @@ """Test that values in cells within a line fulfill the required criteria""" +import re from random import randint from hypothesis import given from hypothesis import strategies as st @@ -9,7 +10,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,}))).*", fullmatch=True)) + r"^(?!(([0-9]+\.([0-9]{3}|[0-9]{6,}))|0+\.?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, @@ -28,7 +29,8 @@ def test_cell_value_errors_with_invalid_inputs2(num_str): "with at least six decimal places.")) @given(num_str=st.from_regex( - r"^[0-9]+\.([0-9]{1,2}|[0-9]{4,}$)", fullmatch=True)) + r"^[0-9]+\.([0-9]{1,2}|[0-9]{4,}$)", fullmatch=True).filter( + lambda param: not re.match(r"0\.0+", param))) def test_cell_average_value_errors_if_not_three_decimal_places2(num_str): """ GIVEN: `num_str` is a string representing a number with less than or more @@ -54,7 +56,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 -@given(num_str=st.from_regex(r"^[0-9]+\.([0-9]{0,5}$)", fullmatch=True)) +@given(num_str=st.from_regex(r"^[0-9]+\.([0-9]{0,5}$)", fullmatch=True).filter( + lambda param: not re.match(r"0\.0+", param))) def test_cell_standard_error_value_errors_if_less_than_six_decimal_places2(num_str): """ GIVEN: `num_str` is a string representing a number with less than six |