-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
redirects indicator tests to BehaviorOphysMetadata testing
- Loading branch information
Showing
2 changed files
with
60 additions
and
56 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
58 changes: 58 additions & 0 deletions
58
allensdk/test/brain_observatory/behavior/test_behavior_ophys_metadata.py
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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import pytest | ||
|
||
from allensdk.brain_observatory.behavior.metadata.behavior_ophys_metadata \ | ||
import BehaviorOphysMetadata | ||
|
||
|
||
def test_indicator(monkeypatch): | ||
"""Test that indicator is parsed from full_genotype""" | ||
|
||
class MockExtractor: | ||
def get_reporter_line(self): | ||
return 'Ai148(TIT2L-GC6f-ICL-tTA2)' | ||
|
||
extractor = MockExtractor() | ||
|
||
with monkeypatch.context() as ctx: | ||
def dummy_init(self): | ||
self._extractor = extractor | ||
|
||
ctx.setattr(BehaviorOphysMetadata, | ||
'__init__', | ||
dummy_init) | ||
|
||
metadata = BehaviorOphysMetadata() | ||
|
||
assert metadata.indicator == 'GCaMP6f' | ||
|
||
|
||
@pytest.mark.parametrize("input_reporter_line, warning_msg, expected", ( | ||
(None, 'Error parsing reporter line. It is null.', None), | ||
('foo', 'Could not parse indicator from reporter because none' | ||
'of the expected substrings were found in the reporter', None) | ||
) | ||
) | ||
def test_indicator_edge_cases(monkeypatch, input_reporter_line, warning_msg, | ||
expected): | ||
"""Test indicator parsing edge cases""" | ||
|
||
class MockExtractor: | ||
def get_reporter_line(self): | ||
return input_reporter_line | ||
|
||
extractor = MockExtractor() | ||
|
||
with monkeypatch.context() as ctx: | ||
def dummy_init(self): | ||
self._extractor = extractor | ||
|
||
ctx.setattr(BehaviorOphysMetadata, | ||
'__init__', | ||
dummy_init) | ||
|
||
metadata = BehaviorOphysMetadata() | ||
|
||
with pytest.warns(UserWarning) as record: | ||
indicator = metadata.indicator | ||
assert indicator is expected | ||
assert str(record[0].message) == warning_msg |