-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make a test that will fail with the current grouper
- Loading branch information
Showing
1 changed file
with
21 additions
and
2 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,13 +1,32 @@ | ||
"""Tests related to the MACCOR parser""" | ||
|
||
import os | ||
|
||
from pytest import fixture | ||
|
||
from batdata.extractors.maccor import MACCORExtractor | ||
|
||
test_file = os.path.join(os.path.dirname(__file__), 'files', 'maccor_example.001') | ||
|
||
|
||
def test_validation(): | ||
@fixture() | ||
def extractor(): | ||
return MACCORExtractor() | ||
|
||
|
||
def test_validation(extractor): | ||
"""Make sure the parser generates valid outputs""" | ||
extractor = MACCORExtractor() | ||
data = extractor.parse_to_dataframe([test_file]) | ||
data.validate_columns(allow_extra_columns=False) | ||
|
||
|
||
def test_grouping(extractor, tmp_path): | ||
# Make a file structure with two sets of experiments and a nonsense file | ||
for f in ['README', 'testA.002', 'testA.001', 'testB.001']: | ||
(tmp_path / f).write_text('junk') | ||
|
||
# Test the grouping | ||
groups = list(extractor.identify_files(tmp_path)) | ||
assert len(groups) == 2 | ||
assert (str(tmp_path / 'testA.001'), str(tmp_path / 'testA.002')) in groups | ||
assert (str(tmp_path / 'testB.001'),) in groups |