Skip to content

Commit

Permalink
redirects indicator tests to BehaviorOphysMetadata testing
Browse files Browse the repository at this point in the history
  • Loading branch information
djkapner committed Aug 4, 2021
1 parent df05c0e commit 578596f
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 56 deletions.
58 changes: 2 additions & 56 deletions allensdk/test/brain_observatory/behavior/test_behavior_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def test_get_task_parameters_task_id_exception():
}

with pytest.raises(RuntimeError) as error:
_ = get_task_parameters(input_data)
get_task_parameters(input_data)
assert "does not know how to parse 'task_id'" in error.value.args[0]


Expand Down Expand Up @@ -285,7 +285,7 @@ def test_get_task_parameters_flash_duration_exception():
}

with pytest.raises(RuntimeError) as error:
_ = get_task_parameters(input_data)
get_task_parameters(input_data)
shld_be = "'images' and/or 'grating' not a valid key"
assert shld_be in error.value.args[0]

Expand Down Expand Up @@ -585,57 +585,3 @@ def dummy_init(self, extractor, behavior_stimulus_file):
obt_date = metadata.date_of_acquisition

assert obt_date == extractor_expt_date


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(BehaviorMetadata,
'__init__',
dummy_init)

metadata = BehaviorMetadata()

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(BehaviorMetadata,
'__init__',
dummy_init)

metadata = BehaviorMetadata()

with pytest.warns(UserWarning) as record:
indicator = metadata.indicator
assert indicator is expected
assert str(record[0].message) == warning_msg
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

0 comments on commit 578596f

Please sign in to comment.