From dead658ae536e2eeb4a87588990409e0b20a34a6 Mon Sep 17 00:00:00 2001 From: Cunliang Geng Date: Fri, 10 Jan 2025 10:29:04 +0100 Subject: [PATCH] add test of download for gnps2 --- .../unit/metabolomics/test_gnps_downloader.py | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/unit/metabolomics/test_gnps_downloader.py b/tests/unit/metabolomics/test_gnps_downloader.py index 583e8bcb..9f2524f8 100644 --- a/tests/unit/metabolomics/test_gnps_downloader.py +++ b/tests/unit/metabolomics/test_gnps_downloader.py @@ -1,3 +1,4 @@ +import tarfile import zipfile import pytest from nplinker.metabolomics.gnps import GNPSDownloader @@ -111,3 +112,22 @@ def test_download_gnps1(task_id, workflow, tmpdir, gnps_zip_files, gnps_website_ expected = zipfile.ZipFile(gnps_zip_files[workflow]) expected_names = expected.namelist() assert actual_names == expected_names + + +@pytest.mark.parametrize( + "task_id, workflow", + [ + ["2014f321d72542afb5216c932e0d5079", GNPSFormat.GNPS2FBMN], + ["206a7b40b7ed41c1ae6b4fbd2def3636", GNPSFormat.GNPS2CN], + ], +) +def test_download_gnps2(task_id, workflow, tmpdir, gnps2_tar_files, gnps2_website_is_down): + if gnps2_website_is_down: + pytest.skip("GNPS2 website is down: https://gnps2.org") + downloader = GNPSDownloader(task_id, tmpdir, gnps_version="2") + downloader.download() + actual = tarfile.open(downloader.get_download_file()) + actual_names = actual.getnames() + expected = tarfile.open(gnps2_tar_files[workflow]) + expected_names = expected.getnames() + assert actual_names == expected_names