-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
23 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,39 @@ | ||
import pytest | ||
from nmrstarlib import nmrstarlib | ||
|
||
|
||
def test_from_local_file(): | ||
starfile_generator = nmrstarlib.read_files("tests/example_data/NMRSTAR3/bmr18569.str", | ||
"tests/example_data/NMRSTAR2/bmr18569.str") | ||
@pytest.mark.parametrize("source", [ | ||
("tests/example_data/NMRSTAR3/bmr18569.str", "tests/example_data/NMRSTAR2/bmr18569.str") | ||
]) | ||
def test_from_local_file(source): | ||
starfile_generator = nmrstarlib.read_files(*source) | ||
starfile1 = next(starfile_generator) | ||
starfile2 = next(starfile_generator) | ||
assert starfile1.bmrbid == "18569" and starfile2.bmrbid == "18569" | ||
|
||
|
||
def test_from_bmrbid(): | ||
starfile_generator = nmrstarlib.read_files("18569") | ||
starfile = next(starfile_generator) | ||
assert starfile.bmrbid == "18569" | ||
|
||
|
||
def test_from_bmrbids(): | ||
starfile_generator = nmrstarlib.read_files("15000", "18569") | ||
@pytest.mark.parametrize("source", [ | ||
("15000", "18569") | ||
]) | ||
def test_from_bmrbid(source): | ||
starfile_generator = nmrstarlib.read_files(*source) | ||
starfile1 = next(starfile_generator) | ||
starfile2 = next(starfile_generator) | ||
assert starfile1.bmrbid in ("15000", "18569") and starfile2.bmrbid in ("15000", "18569") | ||
|
||
|
||
def test_from_directory(): | ||
starfile_generator = nmrstarlib.read_files("tests/example_data/NMRSTAR3/starfiles_directory", | ||
"tests/example_data/NMRSTAR3/starfiles_directory") | ||
starfiles_list = list(starfile_generator) | ||
starfiles_ids_set = set(sf.bmrbid for sf in starfiles_list) | ||
assert starfiles_ids_set == {"15000", "18569"} | ||
|
||
|
||
def test_from_zip_archive(): | ||
starfile_generator = nmrstarlib.read_files("tests/example_data/NMRSTAR3/starfiles_archive.zip", | ||
"tests/example_data/NMRSTAR2/starfiles_archive.zip") | ||
starfiles_list = list(starfile_generator) | ||
starfiles_ids_set = set(sf.bmrbid for sf in starfiles_list) | ||
assert starfiles_ids_set == {"15000", "18569"} | ||
|
||
|
||
def test_from_tar_gz_archive(): | ||
starfile_generator = nmrstarlib.read_files("tests/example_data/NMRSTAR3/starfiles_archive.tar.gz", | ||
"tests/example_data/NMRSTAR2/starfiles_archive.tar.gz") | ||
starfiles_list = list(starfile_generator) | ||
starfiles_ids_set = set(sf.bmrbid for sf in starfiles_list) | ||
assert starfiles_ids_set == {"15000", "18569"} | ||
|
||
|
||
def test_from_tar_bz2_archive(): | ||
starfile_generator = nmrstarlib.read_files("tests/example_data/NMRSTAR3/starfiles_archive.tar.bz2", | ||
"tests/example_data/NMRSTAR2/starfiles_archive.tar.bz2") | ||
@pytest.mark.parametrize("source", [ | ||
"tests/example_data/NMRSTAR3/starfiles_directory", | ||
"tests/example_data/NMRSTAR2/starfiles_directory", | ||
"tests/example_data/NMRSTAR3/starfiles_archive.zip", | ||
"tests/example_data/NMRSTAR2/starfiles_archive.zip", | ||
"tests/example_data/NMRSTAR3/starfiles_archive.tar.gz", | ||
"tests/example_data/NMRSTAR2/starfiles_archive.tar.gz", | ||
"tests/example_data/NMRSTAR3/starfiles_archive.tar.bz2", | ||
"tests/example_data/NMRSTAR2/starfiles_archive.tar.bz2" | ||
]) | ||
def test_reading(source): | ||
starfile_generator = nmrstarlib.read_files(source) | ||
starfiles_list = list(starfile_generator) | ||
starfiles_ids_set = set(sf.bmrbid for sf in starfiles_list) | ||
assert starfiles_ids_set == {"15000", "18569"} |