def testReportCreation (self): """ Returned dictionary should be correct and have the same length, name as test files """ zipPath = os.path.join (os.getcwd(), "tests", "zip_files") zipList = fastqc_reports.get_file_list (zipPath, True) dirPath = os.path.join (os.getcwd(), "tests", "report_folders") dirList = fastqc_reports.get_file_list (dirPath, False) zipDict = fastqc_reports.combine_reports (zipList, True) dirDict = fastqc_reports.combine_reports (dirList, False) self.assertIsInstance (zipDict, dict) self.assertIsInstance (dirDict, dict) self.assertEqual (len(zipDict), 5) self.assertEqual (len(dirDict), 3) self.assertIn ("test", zipDict) self.assertIn ("001_f", dirDict) self.assertEqual (len (zipDict["test"]), 12) self.assertEqual (len (dirDict["001_f"]), 12) self.assertEqual (zipDict["test"]['Basic Statistics'], 'PASS') self.assertEqual (dirDict["001_f"]['Basic Statistics'], 'PASS')
def testListFiles (self): """Given folder should contain needable files""" # Test works only if calles from parent directory path = os.getcwd() no_files = os.path.join (path, "tests/no_files") zip_files = os.path.join (path, "tests/zip_files") folder_files = os.path.join (path, "tests/report_folders") # Make folders for this test if not os.path.exists(no_files): os.mkdir (no_files) # Error if empty folder is given self.assertRaises (fastqc_reports.TypeError, fastqc_reports.get_file_list, no_files, False) # Error if folder with no report .zip files self.assertRaises(fastqc_reports.TypeError, fastqc_reports.get_file_list, folder_files, True) # Error if folder without report folders self.assertRaises(fastqc_reports.TypeError, fastqc_reports.get_file_list, zip_files, False) # Return exact numbers of files in the folder self.assertEqual (len (fastqc_reports.get_file_list (zip_files, True)), 5) self.assertEqual (len (fastqc_reports.get_file_list (folder_files, False)), 3) os.rmdir (no_files)