diff options
author | BonfaceKilz | 2022-03-12 17:59:50 +0300 |
---|---|---|
committer | BonfaceKilz | 2022-03-12 18:01:22 +0300 |
commit | 046f184c63c48c19e4d807032623e5a4bfaaac3b (patch) | |
tree | 3184d98e23cbea897cb25566eb9bb496e36f6db1 /tests/unit/test_csvcmp.py | |
parent | 67a7d919f99a16cab36e4d4997de5706d859d30d (diff) | |
download | genenetwork3-046f184c63c48c19e4d807032623e5a4bfaaac3b.tar.gz |
Fix pylint errors in unit_tests
Diffstat (limited to 'tests/unit/test_csvcmp.py')
-rw-r--r-- | tests/unit/test_csvcmp.py | 88 |
1 files changed, 47 insertions, 41 deletions
diff --git a/tests/unit/test_csvcmp.py b/tests/unit/test_csvcmp.py index 3c9ba33..c7ffe2f 100644 --- a/tests/unit/test_csvcmp.py +++ b/tests/unit/test_csvcmp.py @@ -1,13 +1,15 @@ +"""Tests for gn3.csvcmp""" +import pytest + from gn3.csvcmp import csv_diff from gn3.csvcmp import fill_csv from gn3.csvcmp import remove_insignificant_edits from gn3.csvcmp import extract_strain_name -import pytest - @pytest.mark.unit_test def test_fill_csv(): + """Test that filling a csv works properly""" test_input = """ Strain Name,Value,SE,Count,Sex BXD1,18,x,0, @@ -20,45 +22,47 @@ BXD1,18,x,0,x BXD12,16,x,x,x BXD14,15,x,x,x BXD15,14,x,x,x""" - assert(fill_csv(test_input, width=5, value="x") == expected_output) + assert fill_csv(test_input, width=5, value="x") == expected_output + @pytest.mark.unit_test def test_remove_insignificant_data(): + """Test that values outside ε are removed/ ignored""" diff_data = { - 'Additions': [], - 'Deletions': [], - 'Modifications': [ - {'Current': '1.000001,3', 'Original': '1,3'}, - {'Current': '1,3', 'Original': '1.000001,3'}, - {'Current': '2.000001,3', 'Original': '2,2'}, - {'Current': '1.01,3', 'Original': '1,2'} - ] + "Additions": [], + "Deletions": [], + "Modifications": [ + {"Current": "1.000001,3", "Original": "1,3"}, + {"Current": "1,3", "Original": "1.000001,3"}, + {"Current": "2.000001,3", "Original": "2,2"}, + {"Current": "1.01,3", "Original": "1,2"}, + ], } expected_json = { - 'Additions': [], - 'Deletions': [], - 'Modifications': [ - {'Current': '2,3', 'Original': '2,2'}, - {'Current': '1.01,3', 'Original': '1,2'} - ] + "Additions": [], + "Deletions": [], + "Modifications": [ + {"Current": "2,3", "Original": "2,2"}, + {"Current": "1.01,3", "Original": "1,2"}, + ], } - assert (remove_insignificant_edits(diff_data) == - expected_json) + assert remove_insignificant_edits(diff_data) == expected_json @pytest.mark.unit_test def test_csv_diff_same_columns(): - assert(csv_diff(base_csv="a,b\n1,2\n", - delta_csv="a,b\n1,3") == { - 'Additions': [], - 'Deletions': [], - 'Columns': '', - 'Modifications': [{'Current': '1,3', - 'Original': '1,2'}]}) + """Test csv diffing on data with the same number of columns""" + assert csv_diff(base_csv="a,b\n1,2\n", delta_csv="a,b\n1,3") == { + "Additions": [], + "Deletions": [], + "Columns": "", + "Modifications": [{"Current": "1,3", "Original": "1,2"}], + } @pytest.mark.unit_test def test_csv_diff_different_columns(): + """Test csv diffing on data with different columns""" base_csv = """ Strain Name,Value,SE,Count BXD1,18,x,0 @@ -71,17 +75,17 @@ BXD1,18,x,0 BXD12,16,x,x,1 BXD14,15,x,x BXD15,14,x,x""" - assert(csv_diff(base_csv=base_csv, - delta_csv=delta_csv) == { - 'Additions': [], - 'Columns': 'Strain Name,Value,SE,Count,Sex', - 'Deletions': [], - 'Modifications': [{'Current': 'BXD12,16,x,x,1', - 'Original': 'BXD12,16,x,x,x'}]}) + assert csv_diff(base_csv=base_csv, delta_csv=delta_csv) == { + "Additions": [], + "Columns": "Strain Name,Value,SE,Count,Sex", + "Deletions": [], + "Modifications": [{"Current": "BXD12,16,x,x,1", "Original": "BXD12,16,x,x,x"}], + } @pytest.mark.unit_test def test_csv_diff_only_column_change(): + """Test csv diffing when only the column header change""" base_csv = """ Strain Name,Value,SE,Count BXD1,18,x,0 @@ -95,15 +99,17 @@ BXD12,16,x,x BXD14,15,x,x BXD15,14,x,x """ - assert(csv_diff(base_csv=base_csv, - delta_csv=delta_csv) == { - 'Additions': [], - 'Deletions': [], - 'Modifications': []}) + assert csv_diff(base_csv=base_csv, delta_csv=delta_csv) == { + "Additions": [], + "Deletions": [], + "Modifications": [], + } @pytest.mark.unit_test def test_extract_strain_name(): - assert(extract_strain_name(csv_header="Strain Name,Value,SE,Count", - data="BXD1,18,x,0") == - "BXD1") + """Test that the strain's name is extracted given a csv header""" + assert ( + extract_strain_name(csv_header="Strain Name,Value,SE,Count", data="BXD1,18,x,0") + == "BXD1" + ) |