From e225054a167086b97923a8449fd0af013ce26933 Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Thu, 24 Feb 2022 17:13:17 +0300 Subject: Create new method for filling csv with a default value * gn3/csvcmp.py (fill_csv): Given a csv text with uneven or incomplete fields whole length are less than width, fill them with a value which defaults to "x". * tests/unit/test_csvcmp.py (test_fill_csv): Test cases for the above. --- tests/unit/test_csvcmp.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'tests') diff --git a/tests/unit/test_csvcmp.py b/tests/unit/test_csvcmp.py index f73865d..716adb5 100644 --- a/tests/unit/test_csvcmp.py +++ b/tests/unit/test_csvcmp.py @@ -1,9 +1,26 @@ from gn3.csvcmp import csv_diff +from gn3.csvcmp import fill_csv from gn3.csvcmp import remove_insignificant_edits import pytest +@pytest.mark.unit_test +def test_fill_csv(): + test_input = """ +Strain Name,Value,SE,Count +BXD1,18,x,0 +BXD12,16,x,x +BXD14,15,x,x +BXD15,14,x,x +""" + expected_output = """Strain Name,Value,SE,Count,Sex +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")) + @pytest.mark.unit_test def test_remove_insignificant_data(): diff_data = { -- cgit v1.2.3