def test_compare_corrupted_md5(delete_config): chmdfile = "ref_prok_rep_genomes.05.tar.gz.md5" create_mock_archives() shutil.rmtree("md5_files") G.create_directory("md5_files") os.chdir(tmpdir) for files in os.listdir(tmpdir): if ( files.startswith("ref_prok_rep_genomes.05") and "tar.gz" not in files ): os.remove(files) with open(chmdfile, "r") as f: for line in f: info = ( line.strip().split(" ")[0][0:-1] + "q67 " + line.strip().split(" ")[1]) with open(chmdfile, "w") as f: f.write(info) getblastdb.download_from_ftp([chmdfile], delete_config) check_part_five(outcome=True) remove_tmp_db() os.chdir("..") if os.path.isdir(tmpdir): shutil.rmtree(tmpdir)
def test_skipdownload_nomd5(delete_config): create_mock_archives() os.chdir(tmpdir) chmdfile = "ref_prok_rep_genomes.05.tar.gz.md5" refmd5 = os.path.join("md5_files", chmdfile) if os.path.isfile(refmd5): os.remove(refmd5) getblastdb.download_from_ftp([chmdfile], delete_config) check_part_five(outcome=True) remove_tmp_db() os.chdir("..") if os.path.isdir(tmpdir): shutil.rmtree(tmpdir)
def test_archiveextract(delete_config): chmdfile = "ref_prok_rep_genomes.05.tar.gz.md5" create_mock_archives() os.chdir(tmpdir) for files in os.listdir(tmpdir): if ( files.startswith("ref_prok_rep_genomes.05") and not files.endswith(".md5") ): os.remove(files) getblastdb.download_from_ftp([chmdfile], delete_config) check_part_five(outcome=True) assert os.path.isfile("ref_prok_rep_genomes.05.tar.gz") is False remove_tmp_db() os.chdir("..") if os.path.isdir(tmpdir): shutil.rmtree(tmpdir)
def test_skipdownload(delete_config): create_mock_archives() os.chdir(tmpdir) chmdfile = "ref_prok_rep_genomes.05.tar.gz.md5" with open(chmdfile, "r") as f: for line in f: info = ( line.strip().split(" ")[0][0:-1] + "k " + line.strip().split(" ")[1]) with open(chmdfile, "w") as f: f.write(info) getblastdb.download_from_ftp([chmdfile], delete_config) check_part_five(outcome=True) remove_tmp_db() os.chdir("..") if os.path.isdir(tmpdir): shutil.rmtree(tmpdir)
def test_compare_md5_files_witharchive(delete_config): chmdfile = "ref_prok_rep_genomes.05.tar.gz.md5" create_mock_archives() os.chdir(tmpdir) for files in os.listdir(tmpdir): if ( files.startswith("ref_prok_rep_genomes.05") and "tar.gz" not in files ): os.remove(files) archive = os.path.join(downdir, "ref_prok_rep_genomes.05.tar.gz") shutil.copy(archive, "ref_prok_rep_genomes.05.tar.gz") getblastdb.download_from_ftp([chmdfile], delete_config) check_part_five(outcome=True) remove_tmp_db() os.chdir("..") if os.path.isdir(tmpdir): shutil.rmtree(tmpdir)
def test_onlymd5(keep_config): chmdfile = "ref_prok_rep_genomes.05.tar.gz.md5" refmd5 = os.path.join("md5_files", chmdfile) create_mock_archives() os.chdir(tmpdir) for files in os.listdir(tmpdir): if ( files.startswith("ref_prok_rep_genomes.05") and not files.endswith(".md5") ): os.remove(files) shutil.copy(chmdfile, refmd5) getblastdb.download_from_ftp([chmdfile], keep_config) check_part_five(outcome=True) assert os.path.isfile("ref_prok_rep_genomes.05.tar.gz") is True remove_tmp_db() os.chdir("..") if os.path.isdir(tmpdir): shutil.rmtree(tmpdir)
def test_compare_md5_archive_changed(delete_config): chmdfile = "ref_prok_rep_genomes.05.tar.gz.md5" archive = chmdfile.split(".md5")[0] create_mock_archives() shutil.rmtree("md5_files") G.create_directory("md5_files") os.chdir(tmpdir) with tarfile.open(archive, "w:gz") as tar: for files in os.listdir(tmpdir): if files.startswith("ref_prok_rep_genomes.05"): tar.add(files) for files in os.listdir(tmpdir): if ( files.startswith("ref_prok_rep_genomes.05") and "tar.gz" not in files ): os.remove(files) getblastdb.download_from_ftp([chmdfile], delete_config) check_part_five(outcome=True) remove_tmp_db() os.chdir("..") if os.path.isdir(tmpdir): shutil.rmtree(tmpdir)
def test_checksum_incorrect(delete_config): create_mock_archives() os.chdir(tmpdir) for files in os.listdir(tmpdir): if ( files.startswith("ref_prok_rep_genomes.05") and not files.endswith(".md5") ): os.remove(files) chmdfile = "ref_prok_rep_genomes.05.tar.gz.md5" with open(chmdfile, "r") as f: for line in f: info = ( line.strip().split(" ")[0][0:-1] + "q67 " + line.strip().split(" ")[1]) with open(chmdfile, "w") as f: f.write(info) with pytest.raises(Exception): getblastdb.download_from_ftp([chmdfile], delete_config) check_part_five(outcome=False) remove_tmp_db() os.chdir("..") if os.path.isdir(tmpdir): shutil.rmtree(tmpdir)