about summary refs log tree commit diff
path: root/tests/uploader/scripts
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi <fredmanglis@gmail.com>2026-11-12 18:23:40 +0000
committerFrederick Muriuki Muriithi <fredmanglis@gmail.com>2026-11-12 14:28:36 -0600
commit44a90e2d26e2bdb31eeb87c525e889894f124782 (patch)
treef9b8fa545d490e5b5c392a0877933f71a3aca984 /tests/uploader/scripts
parentf5e19ddcc8e4657b25b840ab5d20dcb3b4544c13 (diff)
downloadgn-uploader-44a90e2d26e2bdb31eeb87c525e889894f124782.tar.gz
Test: cover non-negative numeric position validation
Add fixtures and tests for negative and non-numeric cM/Mb values in both
orientations, confirm non-negative integers/floats are accepted, and cover
job-error extraction for invalid positions.

Co-authored-by: pi coding agent <pi@pi.dev>
Diffstat (limited to 'tests/uploader/scripts')
-rw-r--r--tests/uploader/scripts/genotypes/test_preprocess_csv_collect_info.py50
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/uploader/scripts/genotypes/test_preprocess_csv_collect_info.py b/tests/uploader/scripts/genotypes/test_preprocess_csv_collect_info.py
index 032cfdb..35e3f0a 100644
--- a/tests/uploader/scripts/genotypes/test_preprocess_csv_collect_info.py
+++ b/tests/uploader/scripts/genotypes/test_preprocess_csv_collect_info.py
@@ -345,3 +345,53 @@ def test_singlethread_flags_invalid_marker_headings_transposed():
     messages = tuple(error.message for error in stats.errors)
     assert any("Empty marker heading." in message for message in messages)
     assert any("missing-value indicator" in message for message in messages)
+
+
+@pytest.mark.unit_test
+def test_accumulate_flags_invalid_position_values_untransposed():
+    """
+    GIVEN: untransposed rows with negative and non-numeric cM/Mb values
+    WHEN: the lines are accumulated
+    THEN: invalid-position errors are recorded
+    """
+    lines = (
+        "Locus,Chr,cM,Mb,s1,s2\n",
+        "m1,1,-1.0,1.0,A,T\n",
+        "m2,1,0.0,abc,T,H\n",
+    )
+    stats = _accumulate(UNTRANSPOSED_HEADERS, UNTRANSPOSED_CONFIG, list(lines))
+    messages = tuple(error.message for error in stats.errors)
+    assert any("Invalid cM value '-1.0'" in message for message in messages)
+    assert any("Invalid Mb value 'abc'" in message for message in messages)
+
+
+@pytest.mark.unit_test
+def test_accumulate_flags_invalid_position_values_transposed():
+    """
+    GIVEN: transposed cM/Mb rows with negative and non-numeric values
+    WHEN: the lines are accumulated
+    THEN: invalid-position errors are recorded
+    """
+    lines = (
+        "Locus,m1,m2\n", "Chr,1,1\n", "cM,-1.0,0.0\n", "Mb,1.0,abc\n",
+        "s1,A,T\n", "s2,T,H\n")
+    stats = _accumulate(TRANSPOSED_HEADERS, TRANSPOSED_CONFIG, list(lines))
+    messages = tuple(error.message for error in stats.errors)
+    assert any("Invalid cM value '-1.0'" in message for message in messages)
+    assert any("Invalid Mb value 'abc'" in message for message in messages)
+
+
+@pytest.mark.unit_test
+def test_accumulate_accepts_non_negative_int_and_float_positions():
+    """
+    GIVEN: positions given as non-negative integers and floats
+    WHEN: the lines are accumulated
+    THEN: no position errors are recorded
+    """
+    lines = (
+        "Locus,Chr,cM,Mb,s1,s2\n",
+        "m1,1,0,1,A,T\n",
+        "m2,1,1.5,2.25,T,H\n",
+    )
+    stats = _accumulate(UNTRANSPOSED_HEADERS, UNTRANSPOSED_CONFIG, list(lines))
+    assert stats.errors == ()