def test_create_report(self): ''' Tests the creation of the final report file ''' # We need to first create the complete metrics dictionary metrics_file = resource_filename(__name__, "data/nist_metrics.msqc") nist_metrics = parse_metrics._extract_nist_metrics(metrics_file) # Add generic metrics nist_metrics['generic'] = parse_metrics._extract_generic_metrics(self.rawfile, time.time()) # Create report (move to the QC directory, otherwise template is not found restore_path = os.getcwd() os.chdir('QC') run_msqc_pipeline._create_report(self.temp_folder, self.rawfilebase, nist_metrics) # Test for presence of the report file report_file = '{0}/{1}'.format(self.temp_folder, 'index.html') self.failUnless(os.path.exists(report_file)) # Return to the test directory os.chdir(restore_path)
def test_extract_generic_metrics(self): ''' Checks the few generic metrics that are shown on each report ''' # Rawfile in this case is only used to get the file size, so substituted by another 'large' file rawfile = self.mzxmlfile # Sleep for one second, this should result in a runtime of 1sec # Note: test failure can be caused by interfering processes increasing runtime time.sleep(1) # Current date / time formatting ctime = time.gmtime() date = '{year}/{month}/{day} - {hour}:{min}'.format(year=time.strftime("%Y", ctime), month=time.strftime("%b", ctime), day=time.strftime("%d", ctime), hour=time.strftime("%H", ctime), min=time.strftime("%M", ctime)) generic_metrics = parse_metrics._extract_generic_metrics(rawfile, self.t_start) self.assertEquals(generic_metrics, {'date': date, 'runtime': '0:00:01', 'f_size': ['File Size (MB)', '97.8']})