diff --git a/term_frag_sel/cli.py b/term_frag_sel/cli.py index 843d17b536ff43df38558879d36b97fc9991aa44..2ca6cf24784c2901fbbf4c3331be4fd98e794d97 100644 --- a/term_frag_sel/cli.py +++ b/term_frag_sel/cli.py @@ -18,6 +18,9 @@ def main(args: argparse.Namespace): Args: args (parser): list of arguments from CLI. """ + if not isinstance(args, argparse.Namespace): + raise TypeError("Input should be argparse.Namespace") + # Create or wipe output file with open(args.output, "w", encoding="utf-8") as _: pass diff --git a/tests/test_cli.py b/tests/test_cli.py index 7865c82086797a9a7721205289e02d0412840128..3b4b121dee99da4862739d4a1b1b69815f83050a 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -3,13 +3,29 @@ import pytest import pandas as pd # from Bio import SeqIO -from term_frag_sel.cli import file_validation # type: ignore +from term_frag_sel.cli import file_validation, main # type: ignore FASTA_FILE = "tests/test_files/test.fasta" CSV_FILE = "tests/test_files/test.csv" +TAB_FILE = "tests/test_files/test_tab.csv" + +_, csv_counts = file_validation(FASTA_FILE, CSV_FILE, ",") +_, tab_counts = file_validation(FASTA_FILE, TAB_FILE, "\t") def test_file(): """Test file_validation function.""" assert isinstance(file_validation(FASTA_FILE, CSV_FILE, ","), tuple[dict, pd.DataFrame]) + assert isinstance(file_validation(FASTA_FILE, TAB_FILE, "\t"), tuple[dict, pd.DataFrame]) + assert csv_counts.equals(tab_counts) + with pytest.raises(FileNotFoundError): - file_validation("", "", ",") + file_validation(FASTA_FILE, "", ",") + with pytest.raises(FileNotFoundError): + file_validation("", CSV_FILE, ",") + with pytest.raises(ValueError): + file_validation(CSV_FILE, CSV_FILE, ",") + +def test_main(): + """Test main() function.""" + with pytest.raises(TypeError): + main("") diff --git a/tests/test_files/test.csv b/tests/test_files/test.csv index 011ccf16ee31338eaf48b5cca13c35b1a9dfa670..82dfa3958470759325adf8a82fec08603137e461 100644 --- a/tests/test_files/test.csv +++ b/tests/test_files/test.csv @@ -1,51 +1,50 @@ -,seqID,count -0,1,120 +0,1,86 1,2,60 -2,3,76 -3,4,141 -4,5,107 -5,6,59 -6,7,121 -7,8,72 -8,9,114 -9,10,126 -10,11,77 -11,12,130 -12,13,146 -13,14,69 -14,15,62 -15,16,93 -16,17,103 -17,18,150 -18,19,140 -19,20,56 -20,21,103 -21,22,115 -22,23,113 -23,24,53 -24,25,95 -25,26,112 -26,27,102 -27,28,53 -28,29,139 -29,30,143 -30,31,150 -31,32,126 -32,33,50 -33,34,94 -34,35,81 -35,36,116 -36,37,51 -37,38,110 -38,39,98 -39,40,60 -40,41,57 -41,42,73 -42,43,143 -43,44,116 -44,45,98 -45,46,139 -46,47,89 -47,48,63 -48,49,68 -49,50,84 +2,3,56 +3,4,129 +4,5,138 +5,6,89 +6,7,107 +7,8,52 +8,9,81 +9,10,83 +10,11,139 +11,12,66 +12,13,105 +13,14,59 +14,15,93 +15,16,134 +16,17,50 +17,18,64 +18,19,110 +19,20,119 +20,21,54 +21,22,105 +22,23,124 +23,24,109 +24,25,125 +25,26,98 +26,27,88 +27,28,55 +28,29,70 +29,30,147 +30,31,123 +31,32,66 +32,33,54 +33,34,60 +34,35,79 +35,36,121 +36,37,69 +37,38,63 +38,39,121 +39,40,149 +40,41,52 +41,42,100 +42,43,54 +43,44,81 +44,45,150 +45,46,116 +46,47,128 +47,48,73 +48,49,144 +49,50,89 diff --git a/tests/test_files/test_tab.csv b/tests/test_files/test_tab.csv new file mode 100644 index 0000000000000000000000000000000000000000..8b7c982db2ef389baa1808462062ff0c19181a6a --- /dev/null +++ b/tests/test_files/test_tab.csv @@ -0,0 +1,50 @@ +0 1 86 +1 2 102 +2 3 81 +3 4 91 +4 5 121 +5 6 82 +6 7 103 +7 8 125 +8 9 135 +9 10 133 +10 11 110 +11 12 108 +12 13 89 +13 14 125 +14 15 76 +15 16 85 +16 17 130 +17 18 63 +18 19 137 +19 20 55 +20 21 148 +21 22 101 +22 23 145 +23 24 99 +24 25 50 +25 26 101 +26 27 134 +27 28 60 +28 29 107 +29 30 134 +30 31 76 +31 32 118 +32 33 99 +33 34 64 +34 35 97 +35 36 118 +36 37 131 +37 38 142 +38 39 119 +39 40 50 +40 41 90 +41 42 65 +42 43 140 +43 44 145 +44 45 84 +45 46 144 +46 47 103 +47 48 96 +48 49 50 +49 50 112