Mercurial > repos > padge > clipkit
comparison clipkit_repo/tests/unit/test_args_parsing.py @ 0:49b058e85902 draft
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
author | padge |
---|---|
date | Fri, 25 Mar 2022 13:04:31 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:49b058e85902 |
---|---|
1 import pytest | |
2 from argparse import Namespace | |
3 from clipkit.modes import TrimmingMode | |
4 from clipkit.args_processing import process_args | |
5 | |
6 | |
7 @pytest.fixture | |
8 def args(): | |
9 kwargs = dict( | |
10 complementary=False, | |
11 gaps=None, | |
12 input="tests/integration/samples/simple.fa", | |
13 input_file_format=None, | |
14 log=False, | |
15 mode=None, | |
16 output="output/simple", | |
17 output_file_format=None, | |
18 ) | |
19 return Namespace(**kwargs) | |
20 | |
21 | |
22 class TestArgsProcessing(object): | |
23 def test_process_args_input_file_dne(self, args): | |
24 args.input = "some/file/that/doesnt/exist" | |
25 with pytest.raises(SystemExit): | |
26 process_args(args) | |
27 | |
28 def test_process_args_in_equals_out(self, args): | |
29 args.output = args.input | |
30 with pytest.raises(SystemExit): | |
31 process_args(args) | |
32 | |
33 def test_process_args_default_mode(self, args): | |
34 res = process_args(args) | |
35 assert res["mode"] == TrimmingMode.smart_gap | |
36 | |
37 def test_process_args_default_complementary(self, args): | |
38 args.complementary = None | |
39 res = process_args(args) | |
40 assert res["complement"] is False | |
41 | |
42 def test_process_args_default_gaps(self, args): | |
43 res = process_args(args) | |
44 assert res["gaps"] == 0.9 | |
45 | |
46 def test_process_args_default_use_logs(self, args): | |
47 args.log = None | |
48 res = process_args(args) | |
49 assert res["use_log"] is False | |
50 | |
51 def test_process_args_default_output_file(self, args): | |
52 args.output = None | |
53 res = process_args(args) | |
54 assert res["output_file"] == f"{args.input}.clipkit" | |
55 | |
56 def test_process_args_expected_keywords(self, args): | |
57 res = process_args(args) | |
58 expected_keys = [ | |
59 "input_file", | |
60 "output_file", | |
61 "input_file_format", | |
62 "output_file_format", | |
63 "complement", | |
64 "gaps", | |
65 "mode", | |
66 "use_log", | |
67 ] | |
68 assert sorted(res.keys()) == sorted(expected_keys) |