annotate test/test_report.py @ 13:bbf9ab2ebee7 draft default tip

planemo upload for repository https://github.com/COMBAT-TB/confil commit fcda5ac2013e3253d68cb6db06acf3b5450dcd0c
author sanbi-uwc
date Tue, 12 Mar 2019 09:16:35 -0400
parents 5ec97cccb3fe
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12
5ec97cccb3fe planemo upload for repository https://github.com/COMBAT-TB/confil commit b1a96c1b50cea70a20d4e606100879da8b6ed1b2
sanbi-uwc
parents:
diff changeset
1 import os
5ec97cccb3fe planemo upload for repository https://github.com/COMBAT-TB/confil commit b1a96c1b50cea70a20d4e606100879da8b6ed1b2
sanbi-uwc
parents:
diff changeset
2
5ec97cccb3fe planemo upload for repository https://github.com/COMBAT-TB/confil commit b1a96c1b50cea70a20d4e606100879da8b6ed1b2
sanbi-uwc
parents:
diff changeset
3 import pytest
5ec97cccb3fe planemo upload for repository https://github.com/COMBAT-TB/confil commit b1a96c1b50cea70a20d4e606100879da8b6ed1b2
sanbi-uwc
parents:
diff changeset
4
5ec97cccb3fe planemo upload for repository https://github.com/COMBAT-TB/confil commit b1a96c1b50cea70a20d4e606100879da8b6ed1b2
sanbi-uwc
parents:
diff changeset
5 from confil.report import parse_report
5ec97cccb3fe planemo upload for repository https://github.com/COMBAT-TB/confil commit b1a96c1b50cea70a20d4e606100879da8b6ed1b2
sanbi-uwc
parents:
diff changeset
6 from test_runner import TEST_DATA_DIR
5ec97cccb3fe planemo upload for repository https://github.com/COMBAT-TB/confil commit b1a96c1b50cea70a20d4e606100879da8b6ed1b2
sanbi-uwc
parents:
diff changeset
7
5ec97cccb3fe planemo upload for repository https://github.com/COMBAT-TB/confil commit b1a96c1b50cea70a20d4e606100879da8b6ed1b2
sanbi-uwc
parents:
diff changeset
8 TEST_REPORT = os.path.join(TEST_DATA_DIR, "test_file.tab")
5ec97cccb3fe planemo upload for repository https://github.com/COMBAT-TB/confil commit b1a96c1b50cea70a20d4e606100879da8b6ed1b2
sanbi-uwc
parents:
diff changeset
9
5ec97cccb3fe planemo upload for repository https://github.com/COMBAT-TB/confil commit b1a96c1b50cea70a20d4e606100879da8b6ed1b2
sanbi-uwc
parents:
diff changeset
10 # test using a cutoff of 50%
5ec97cccb3fe planemo upload for repository https://github.com/COMBAT-TB/confil commit b1a96c1b50cea70a20d4e606100879da8b6ed1b2
sanbi-uwc
parents:
diff changeset
11
5ec97cccb3fe planemo upload for repository https://github.com/COMBAT-TB/confil commit b1a96c1b50cea70a20d4e606100879da8b6ed1b2
sanbi-uwc
parents:
diff changeset
12
5ec97cccb3fe planemo upload for repository https://github.com/COMBAT-TB/confil commit b1a96c1b50cea70a20d4e606100879da8b6ed1b2
sanbi-uwc
parents:
diff changeset
13 @pytest.mark.parametrize("test_input, expected", [
5ec97cccb3fe planemo upload for repository https://github.com/COMBAT-TB/confil commit b1a96c1b50cea70a20d4e606100879da8b6ed1b2
sanbi-uwc
parents:
diff changeset
14 (type(parse_report(TEST_REPORT, 50)), list),
5ec97cccb3fe planemo upload for repository https://github.com/COMBAT-TB/confil commit b1a96c1b50cea70a20d4e606100879da8b6ed1b2
sanbi-uwc
parents:
diff changeset
15 (parse_report(TEST_REPORT, 50)[5], 'Mycobacterium'),
5ec97cccb3fe planemo upload for repository https://github.com/COMBAT-TB/confil commit b1a96c1b50cea70a20d4e606100879da8b6ed1b2
sanbi-uwc
parents:
diff changeset
16 (parse_report(TEST_REPORT, 50)[0], '55.84')
5ec97cccb3fe planemo upload for repository https://github.com/COMBAT-TB/confil commit b1a96c1b50cea70a20d4e606100879da8b6ed1b2
sanbi-uwc
parents:
diff changeset
17 ])
5ec97cccb3fe planemo upload for repository https://github.com/COMBAT-TB/confil commit b1a96c1b50cea70a20d4e606100879da8b6ed1b2
sanbi-uwc
parents:
diff changeset
18 def test_parse_report(test_input, expected):
5ec97cccb3fe planemo upload for repository https://github.com/COMBAT-TB/confil commit b1a96c1b50cea70a20d4e606100879da8b6ed1b2
sanbi-uwc
parents:
diff changeset
19 assert test_input == expected
5ec97cccb3fe planemo upload for repository https://github.com/COMBAT-TB/confil commit b1a96c1b50cea70a20d4e606100879da8b6ed1b2
sanbi-uwc
parents:
diff changeset
20
5ec97cccb3fe planemo upload for repository https://github.com/COMBAT-TB/confil commit b1a96c1b50cea70a20d4e606100879da8b6ed1b2
sanbi-uwc
parents:
diff changeset
21
5ec97cccb3fe planemo upload for repository https://github.com/COMBAT-TB/confil commit b1a96c1b50cea70a20d4e606100879da8b6ed1b2
sanbi-uwc
parents:
diff changeset
22 def test_parse_report_exception():
5ec97cccb3fe planemo upload for repository https://github.com/COMBAT-TB/confil commit b1a96c1b50cea70a20d4e606100879da8b6ed1b2
sanbi-uwc
parents:
diff changeset
23 with pytest.raises(SystemExit):
5ec97cccb3fe planemo upload for repository https://github.com/COMBAT-TB/confil commit b1a96c1b50cea70a20d4e606100879da8b6ed1b2
sanbi-uwc
parents:
diff changeset
24 parse_report(TEST_REPORT, 90)
5ec97cccb3fe planemo upload for repository https://github.com/COMBAT-TB/confil commit b1a96c1b50cea70a20d4e606100879da8b6ed1b2
sanbi-uwc
parents:
diff changeset
25 parse_report(TEST_REPORT, 20)