take advantage of absolute_import to simplify import statements
[htsworkflow.git] / htsworkflow / pipelines / test / test_summary.py
1 #!/usr/bin/env python
2 from __future__ import absolute_import
3
4 import os
5 from six.moves import StringIO
6 from unittest import TestCase
7
8 from htsworkflow.pipelines import summary
9 from .simulate_runfolder import TESTDATA_DIR
10
11 class SummaryTests(TestCase):
12     """Test elements of the summary file parser
13     """
14     def test_is_xml(self):
15         xmlfile = StringIO('<?xml version="1.0"?>\n<tag>\n')
16         htmlfile = StringIO('<html>\n<head></head>\n<body><p></p></body>\n</html>')
17
18         self.failUnlessEqual(summary.isxml_stream(xmlfile), True)
19         self.failUnlessEqual(xmlfile.tell(), 0)
20
21         self.failUnlessEqual(summary.isxml_stream(htmlfile), False)
22
23     def test_xml_summary_file(self):
24         pathname = os.path.join(TESTDATA_DIR, 'Summary-casava1.7.xml')
25         s = summary.SummaryGA(pathname)
26         self.failUnlessEqual(len(s.lane_results[0]), 8)
27         self.failUnlessEqual(s.lane_results[0][1].cluster, (1073893, 146344))
28
29     def test_html_summary_file(self):
30         pathname = os.path.join(TESTDATA_DIR, 'Summary-ipar130.htm')
31         s = summary.SummaryGA(pathname)
32         self.failUnlessEqual(len(s.lane_results[0]), 8)
33         self.failUnlessEqual(s.lane_results[0][1].cluster, (126910, 4300))
34
35     def test_hiseq_sample_summary_file(self):
36         pathname = os.path.join(TESTDATA_DIR, 'sample_summary_1_12.htm')
37         s = summary.SummaryGA(pathname)
38
39
40 def suite():
41     from unittest import TestSuite, defaultTestLoader
42     suite = TestSuite()
43     suite.addTests(defaultTestLoader.loadTestsFromTestCase(SummaryTests))
44     return suite
45
46
47 if __name__ == "__main__":
48     from unittest import main
49     main(defaultTest="suite")