diff options
| author | pi coding agent <pi@localhost> | 2026-11-04 19:08:44 +0000 |
|---|---|---|
| committer | Frederick Muriuki Muriithi <fredmanglis@gmail.com> | 2026-11-04 13:28:11 -0600 |
| commit | 718777873f56170cabf06801076788e66ff60d45 (patch) | |
| tree | defc2461fd56641864b04a99844c1ffaa4f2b98b /tests/uploader/scripts | |
| parent | bcb0363e4c8a0001050a7e6fbacb8464e6be1f61 (diff) | |
| download | gn-uploader-718777873f56170cabf06801076788e66ff60d45.tar.gz | |
Test: cover collecting comment lines into the file description
Add tests for cleaning comment lines (strip the comment character and surrounding whitespace), honouring a configured comment character, exposing the description on FileStats, and preserving comment order when merging chunks.
Diffstat (limited to 'tests/uploader/scripts')
| -rw-r--r-- | tests/uploader/scripts/genotypes/test_merge_chunk_stats.py | 13 | ||||
| -rw-r--r-- | tests/uploader/scripts/genotypes/test_preprocess_csv_collect_info.py | 34 |
2 files changed, 47 insertions, 0 deletions
diff --git a/tests/uploader/scripts/genotypes/test_merge_chunk_stats.py b/tests/uploader/scripts/genotypes/test_merge_chunk_stats.py index 96b19bd..8973313 100644 --- a/tests/uploader/scripts/genotypes/test_merge_chunk_stats.py +++ b/tests/uploader/scripts/genotypes/test_merge_chunk_stats.py @@ -104,3 +104,16 @@ def test_merge_all_chunk_stats_folds_in_order(): merged = _merge_all_chunk_stats(chunks, transposed=False) assert merged.total_lines == 6 assert merged.markers == ("m1", "m2", "m3") + + +@pytest.mark.unit_test +def test_merge_chunk_stats_concatenates_comments_in_order(): + """ + GIVEN: two sets of chunk statistics with comment text + WHEN: they are merged + THEN: the comment lines are concatenated in file order + """ + left = _ChunkStats(comments=("first",)) + right = _ChunkStats(comments=("second", "third")) + merged = _merge_chunk_stats(left, right, transposed=False) + assert merged.comments == ("first", "second", "third") 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 a45927c..71e0c6c 100644 --- a/tests/uploader/scripts/genotypes/test_preprocess_csv_collect_info.py +++ b/tests/uploader/scripts/genotypes/test_preprocess_csv_collect_info.py @@ -82,6 +82,7 @@ def test_accumulate_collects_symbols_markers_and_dot_geno_fields(): assert stats.dot_geno_fields == { "name": "test", "mat": "A", "pat": "B", "het": "H"} assert stats.errors == () + assert stats.comments == ("a comment",) @pytest.mark.unit_test @@ -123,6 +124,39 @@ def test_singlethread_reports_expected_file_stats(): assert stats.dot_geno_fields == DotGenoFields( name="test", mat="A", pat="B", het="H") assert stats.errors == () + assert stats.description == "a comment" + + +@pytest.mark.unit_test +def test_accumulate_collects_clean_comment_lines(): + """ + GIVEN: comment lines with the comment character and surrounding whitespace + WHEN: the lines are accumulated + THEN: the cleaned comment text is collected in file order + """ + lines = ( + "# first comment \n", + "#second comment\n", + "#\n", + "m1,1,0.0,1.0,A,T\n", + ) + stats = _accumulate(UNTRANSPOSED_HEADERS, UNTRANSPOSED_CONFIG, list(lines)) + assert stats.comments == ("first comment", "second comment", "") + assert stats.comment_lines == 3 + + +@pytest.mark.unit_test +def test_accumulate_uses_the_configured_comment_character(): + """ + GIVEN: a file whose comment character is not '#' + WHEN: the lines are accumulated + THEN: comments are detected and cleaned using the configured character + """ + config = {**UNTRANSPOSED_CONFIG, "comment.char": "//"} + lines = ("// a comment\n", "m1,1,0.0,1.0,A,T\n") + stats = _accumulate(UNTRANSPOSED_HEADERS, config, list(lines)) + assert stats.comment_lines == 1 + assert stats.comments == ("a comment",) @pytest.mark.unit_test |
