Mercurial > repos > sanbi-uwc > confil
annotate test/test_runner.py @ 11:72cb19a32d8b draft
planemo upload for repository https://github.com/COMBAT-TB/confil commit 036172521321dbafe62e6d72b3a491f4bc4b9dc9-dirty
| author | sanbi-uwc | 
|---|---|
| date | Fri, 08 Mar 2019 13:55:10 -0500 | 
| parents | 2b90d0574ea5 | 
| children | 5ec97cccb3fe | 
| rev | line source | 
|---|---|
| 3 
53a61865e86e
planemo upload for repository https://github.com/COMBAT-TB/confil commit cb48efaef286f70c94607cb583a61bb9e3d71604
 sanbi-uwc parents: diff
changeset | 1 import os | 
| 
53a61865e86e
planemo upload for repository https://github.com/COMBAT-TB/confil commit cb48efaef286f70c94607cb583a61bb9e3d71604
 sanbi-uwc parents: diff
changeset | 2 | 
| 
53a61865e86e
planemo upload for repository https://github.com/COMBAT-TB/confil commit cb48efaef286f70c94607cb583a61bb9e3d71604
 sanbi-uwc parents: diff
changeset | 3 import pytest | 
| 
53a61865e86e
planemo upload for repository https://github.com/COMBAT-TB/confil commit cb48efaef286f70c94607cb583a61bb9e3d71604
 sanbi-uwc parents: diff
changeset | 4 from click.testing import CliRunner | 
| 
53a61865e86e
planemo upload for repository https://github.com/COMBAT-TB/confil commit cb48efaef286f70c94607cb583a61bb9e3d71604
 sanbi-uwc parents: diff
changeset | 5 | 
| 6 
2b90d0574ea5
planemo upload for repository https://github.com/COMBAT-TB/confil commit c84738cfc4876c591d7108229038a4001f836afb
 sanbi-uwc parents: 
3diff
changeset | 6 from confil.confil import confil, parse_report | 
| 3 
53a61865e86e
planemo upload for repository https://github.com/COMBAT-TB/confil commit cb48efaef286f70c94607cb583a61bb9e3d71604
 sanbi-uwc parents: diff
changeset | 7 | 
| 
53a61865e86e
planemo upload for repository https://github.com/COMBAT-TB/confil commit cb48efaef286f70c94607cb583a61bb9e3d71604
 sanbi-uwc parents: diff
changeset | 8 CURR_DIR = os.path.dirname(os.path.abspath(__file__)) | 
| 
53a61865e86e
planemo upload for repository https://github.com/COMBAT-TB/confil commit cb48efaef286f70c94607cb583a61bb9e3d71604
 sanbi-uwc parents: diff
changeset | 9 TEST_DATA_DIR = os.path.join(CURR_DIR, "test_data/") | 
| 6 
2b90d0574ea5
planemo upload for repository https://github.com/COMBAT-TB/confil commit c84738cfc4876c591d7108229038a4001f836afb
 sanbi-uwc parents: 
3diff
changeset | 10 TEST_REPORT = os.path.join(TEST_DATA_DIR, "test_file.tab") | 
| 3 
53a61865e86e
planemo upload for repository https://github.com/COMBAT-TB/confil commit cb48efaef286f70c94607cb583a61bb9e3d71604
 sanbi-uwc parents: diff
changeset | 11 FILE_1 = os.path.join(TEST_DATA_DIR, "test_file_1.fastq") | 
| 
53a61865e86e
planemo upload for repository https://github.com/COMBAT-TB/confil commit cb48efaef286f70c94607cb583a61bb9e3d71604
 sanbi-uwc parents: diff
changeset | 12 FILE_2 = os.path.join(TEST_DATA_DIR, "test_file_2.fastq") | 
| 
53a61865e86e
planemo upload for repository https://github.com/COMBAT-TB/confil commit cb48efaef286f70c94607cb583a61bb9e3d71604
 sanbi-uwc parents: diff
changeset | 13 | 
| 
53a61865e86e
planemo upload for repository https://github.com/COMBAT-TB/confil commit cb48efaef286f70c94607cb583a61bb9e3d71604
 sanbi-uwc parents: diff
changeset | 14 | 
| 
53a61865e86e
planemo upload for repository https://github.com/COMBAT-TB/confil commit cb48efaef286f70c94607cb583a61bb9e3d71604
 sanbi-uwc parents: diff
changeset | 15 @pytest.fixture(scope="module") | 
| 
53a61865e86e
planemo upload for repository https://github.com/COMBAT-TB/confil commit cb48efaef286f70c94607cb583a61bb9e3d71604
 sanbi-uwc parents: diff
changeset | 16 def cli_runner(): | 
| 
53a61865e86e
planemo upload for repository https://github.com/COMBAT-TB/confil commit cb48efaef286f70c94607cb583a61bb9e3d71604
 sanbi-uwc parents: diff
changeset | 17 runner = CliRunner() | 
| 
53a61865e86e
planemo upload for repository https://github.com/COMBAT-TB/confil commit cb48efaef286f70c94607cb583a61bb9e3d71604
 sanbi-uwc parents: diff
changeset | 18 return runner | 
| 
53a61865e86e
planemo upload for repository https://github.com/COMBAT-TB/confil commit cb48efaef286f70c94607cb583a61bb9e3d71604
 sanbi-uwc parents: diff
changeset | 19 | 
| 
53a61865e86e
planemo upload for repository https://github.com/COMBAT-TB/confil commit cb48efaef286f70c94607cb583a61bb9e3d71604
 sanbi-uwc parents: diff
changeset | 20 | 
| 6 
2b90d0574ea5
planemo upload for repository https://github.com/COMBAT-TB/confil commit c84738cfc4876c591d7108229038a4001f836afb
 sanbi-uwc parents: 
3diff
changeset | 21 @pytest.mark.skip(reason="No way of currently testing this. It's KRAKEN!") | 
| 3 
53a61865e86e
planemo upload for repository https://github.com/COMBAT-TB/confil commit cb48efaef286f70c94607cb583a61bb9e3d71604
 sanbi-uwc parents: diff
changeset | 22 def test_runner(cli_runner): | 
| 
53a61865e86e
planemo upload for repository https://github.com/COMBAT-TB/confil commit cb48efaef286f70c94607cb583a61bb9e3d71604
 sanbi-uwc parents: diff
changeset | 23 result = cli_runner.invoke(confil, ["--paired", FILE_1, FILE_2]) | 
| 
53a61865e86e
planemo upload for repository https://github.com/COMBAT-TB/confil commit cb48efaef286f70c94607cb583a61bb9e3d71604
 sanbi-uwc parents: diff
changeset | 24 assert result.exit_code == 0 | 
| 6 
2b90d0574ea5
planemo upload for repository https://github.com/COMBAT-TB/confil commit c84738cfc4876c591d7108229038a4001f836afb
 sanbi-uwc parents: 
3diff
changeset | 25 | 
| 
2b90d0574ea5
planemo upload for repository https://github.com/COMBAT-TB/confil commit c84738cfc4876c591d7108229038a4001f836afb
 sanbi-uwc parents: 
3diff
changeset | 26 | 
| 
2b90d0574ea5
planemo upload for repository https://github.com/COMBAT-TB/confil commit c84738cfc4876c591d7108229038a4001f836afb
 sanbi-uwc parents: 
3diff
changeset | 27 @pytest.mark.parametrize("test_input, expected", [ | 
| 
2b90d0574ea5
planemo upload for repository https://github.com/COMBAT-TB/confil commit c84738cfc4876c591d7108229038a4001f836afb
 sanbi-uwc parents: 
3diff
changeset | 28 (type(parse_report(TEST_REPORT, 50)), list), | 
| 
2b90d0574ea5
planemo upload for repository https://github.com/COMBAT-TB/confil commit c84738cfc4876c591d7108229038a4001f836afb
 sanbi-uwc parents: 
3diff
changeset | 29 (parse_report(TEST_REPORT, 50)[5], 'Mycobacterium'), | 
| 
2b90d0574ea5
planemo upload for repository https://github.com/COMBAT-TB/confil commit c84738cfc4876c591d7108229038a4001f836afb
 sanbi-uwc parents: 
3diff
changeset | 30 (parse_report(TEST_REPORT, 50)[0], '55.84') | 
| 
2b90d0574ea5
planemo upload for repository https://github.com/COMBAT-TB/confil commit c84738cfc4876c591d7108229038a4001f836afb
 sanbi-uwc parents: 
3diff
changeset | 31 ]) | 
| 
2b90d0574ea5
planemo upload for repository https://github.com/COMBAT-TB/confil commit c84738cfc4876c591d7108229038a4001f836afb
 sanbi-uwc parents: 
3diff
changeset | 32 def test_parse_report(test_input, expected): | 
| 
2b90d0574ea5
planemo upload for repository https://github.com/COMBAT-TB/confil commit c84738cfc4876c591d7108229038a4001f836afb
 sanbi-uwc parents: 
3diff
changeset | 33 assert test_input == expected | 
| 
2b90d0574ea5
planemo upload for repository https://github.com/COMBAT-TB/confil commit c84738cfc4876c591d7108229038a4001f836afb
 sanbi-uwc parents: 
3diff
changeset | 34 | 
| 
2b90d0574ea5
planemo upload for repository https://github.com/COMBAT-TB/confil commit c84738cfc4876c591d7108229038a4001f836afb
 sanbi-uwc parents: 
3diff
changeset | 35 | 
| 
2b90d0574ea5
planemo upload for repository https://github.com/COMBAT-TB/confil commit c84738cfc4876c591d7108229038a4001f836afb
 sanbi-uwc parents: 
3diff
changeset | 36 def test_parse_report_exception(): | 
| 
2b90d0574ea5
planemo upload for repository https://github.com/COMBAT-TB/confil commit c84738cfc4876c591d7108229038a4001f836afb
 sanbi-uwc parents: 
3diff
changeset | 37 with pytest.raises(SystemExit): | 
| 
2b90d0574ea5
planemo upload for repository https://github.com/COMBAT-TB/confil commit c84738cfc4876c591d7108229038a4001f836afb
 sanbi-uwc parents: 
3diff
changeset | 38 parse_report(TEST_REPORT, 90) | 
