Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alessandratrapani committed Dec 19, 2024
1 parent f191e47 commit e8ba1bd
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 17 deletions.
7 changes: 4 additions & 3 deletions spec/ndx-microscopy.extensions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ groups:
- name: description
dtype: text
doc: Description of the emission light path.
groups:
- neurodata_type_inc: Indicator
doc: Indicator object which contains metadata about the indicator used in this light path.
quantity: 1
links:
- name: photodetector
target_type: Photodetector
Expand All @@ -48,9 +52,6 @@ groups:
target_type: OpticalFilter
doc: Link to OpticalFilter object which contains metadata about the optical filter in this emission light path. It can be either a BandOpticalFilter (e.g., 'Bandpass', 'Bandstop', 'Longpass', 'Shortpass') or a EdgeOpticalFilter (Longpass or Shortpass).
required: false
- name: indicator
target_type: Indicator
doc: Link to Indicator object which contains metadata about the indicator used in this light path.

- neurodata_type_def: ImagingSpace
neurodata_type_inc: LabMetaData # Would prefer basic NWBContainer
Expand Down
108 changes: 94 additions & 14 deletions src/pynwb/tests/test_roundtrip.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
"""Test roundtrip (write and read back) of the Python API for the ndx-microscopy extension."""
from datetime import datetime

from ndx_ophys_devices import Photodetector
from pytz import UTC
import pytest
from pynwb.testing import TestCase as pynwb_TestCase
from pynwb.testing.mock.file import mock_NWBFile

import pynwb
from ndx_ophys_devices.testing import mock_ExcitationSource, mock_Photodetector, mock_OpticalFilter
from ndx_microscopy.testing import (
mock_EmissionLightPath,
mock_ExcitationLightPath,
Expand All @@ -31,18 +35,38 @@ def tearDown(self):
pynwb.testing.remove_test_file(self.nwbfile_path)

def test_roundtrip(self):
nwbfile = mock_NWBFile()
nwbfile = mock_NWBFile(session_start_time=datetime(2000, 1, 1, tzinfo=UTC))

microscope = mock_Microscope(name="Microscope")
nwbfile.add_device(devices=microscope)

excitation_light_path = mock_ExcitationLightPath(name="ExcitationLightPath")
excitation_source=mock_ExcitationSource()
nwbfile.add_device(devices=excitation_source)

excitation_filter=mock_OpticalFilter()
nwbfile.add_device(devices=excitation_filter)

excitation_light_path = mock_ExcitationLightPath(
name="ExcitationLightPath",
excitation_source=excitation_source,
excitation_filter=excitation_filter
)
nwbfile.add_lab_meta_data(lab_meta_data=excitation_light_path)

imaging_space = mock_PlanarImagingSpace(name="PlanarImagingSpace")
nwbfile.add_lab_meta_data(lab_meta_data=imaging_space) # Would prefer .add_imaging_spacec()

emission_light_path = mock_EmissionLightPath(name="EmissionLightPath")
photodetector=mock_Photodetector()
nwbfile.add_device(devices=photodetector)

emission_filter=mock_OpticalFilter()
nwbfile.add_device(devices=emission_filter)

emission_light_path = mock_EmissionLightPath(
name="EmissionLightPath",
emission_filter=emission_filter,
photodetector=photodetector
)
nwbfile.add_lab_meta_data(lab_meta_data=emission_light_path)

planar_microscopy_series = mock_PlanarMicroscopySeries(
Expand Down Expand Up @@ -79,18 +103,38 @@ def tearDown(self):
pynwb.testing.remove_test_file(self.nwbfile_path)

def test_roundtrip(self):
nwbfile = mock_NWBFile()
nwbfile = mock_NWBFile(session_start_time=datetime(2000, 1, 1, tzinfo=UTC))

microscope = mock_Microscope(name="Microscope")
nwbfile.add_device(devices=microscope)

excitation_light_path = mock_ExcitationLightPath(name="ExcitationLightPath")
excitation_source=mock_ExcitationSource()
nwbfile.add_device(devices=excitation_source)

excitation_filter=mock_OpticalFilter()
nwbfile.add_device(devices=excitation_filter)

excitation_light_path = mock_ExcitationLightPath(
name="ExcitationLightPath",
excitation_source=excitation_source,
excitation_filter=excitation_filter
)
nwbfile.add_lab_meta_data(lab_meta_data=excitation_light_path)

imaging_space = mock_VolumetricImagingSpace(name="VolumetricImagingSpace")
nwbfile.add_lab_meta_data(lab_meta_data=imaging_space) # Would prefer .add_imaging_spacec()

emission_light_path = mock_EmissionLightPath(name="EmissionLightPath")
photodetector=mock_Photodetector()
nwbfile.add_device(devices=photodetector)

emission_filter=mock_OpticalFilter()
nwbfile.add_device(devices=emission_filter)

emission_light_path = mock_EmissionLightPath(
name="EmissionLightPath",
emission_filter=emission_filter,
photodetector=photodetector
)
nwbfile.add_lab_meta_data(lab_meta_data=emission_light_path)

volumetric_microscopy_series = mock_VolumetricMicroscopySeries(
Expand Down Expand Up @@ -129,18 +173,38 @@ def tearDown(self):
pynwb.testing.remove_test_file(self.nwbfile_path)

def test_roundtrip(self):
nwbfile = mock_NWBFile()
nwbfile = mock_NWBFile(session_start_time=datetime(2000, 1, 1, tzinfo=UTC))

microscope = mock_Microscope(name="Microscope")
nwbfile.add_device(devices=microscope)

excitation_light_path = mock_ExcitationLightPath(name="ExcitationLightPath")
excitation_source=mock_ExcitationSource()
nwbfile.add_device(devices=excitation_source)

excitation_filter=mock_OpticalFilter()
nwbfile.add_device(devices=excitation_filter)

excitation_light_path = mock_ExcitationLightPath(
name="ExcitationLightPath",
excitation_source=excitation_source,
excitation_filter=excitation_filter
)
nwbfile.add_lab_meta_data(lab_meta_data=excitation_light_path)

imaging_space = mock_PlanarImagingSpace(name="PlanarImagingSpace")
nwbfile.add_lab_meta_data(lab_meta_data=imaging_space) # Would prefer .add_imaging_space()

emission_light_path = mock_EmissionLightPath(name="EmissionLightPath")
photodetector=mock_Photodetector()
nwbfile.add_device(devices=photodetector)

emission_filter=mock_OpticalFilter()
nwbfile.add_device(devices=emission_filter)

emission_light_path = mock_EmissionLightPath(
name="EmissionLightPath",
emission_filter=emission_filter,
photodetector=photodetector
)
nwbfile.add_lab_meta_data(lab_meta_data=emission_light_path)

variable_depth_microscopy_series = mock_VariableDepthMicroscopySeries(
Expand Down Expand Up @@ -179,7 +243,7 @@ def tearDown(self):
pynwb.testing.remove_test_file(self.nwbfile_path)

def test_roundtrip(self):
nwbfile = mock_NWBFile()
nwbfile = mock_NWBFile(session_start_time=datetime(2000, 1, 1, tzinfo=UTC))

microscope = mock_Microscope(name="Microscope")
nwbfile.add_device(devices=microscope)
Expand All @@ -188,12 +252,28 @@ def test_roundtrip(self):
nwbfile.add_lab_meta_data(lab_meta_data=imaging_space) # Would prefer .add_imaging_space()

excitation_light_paths = list()
excitation_light_path_0 = mock_ExcitationLightPath(name="ExcitationLightPath")
excitation_source=mock_ExcitationSource()
nwbfile.add_device(devices=excitation_source)
excitation_filter=mock_OpticalFilter()
nwbfile.add_device(devices=excitation_filter)
excitation_light_path_0 = mock_ExcitationLightPath(
name="ExcitationLightPath",
excitation_source=excitation_source,
excitation_filter=excitation_filter
)
nwbfile.add_lab_meta_data(lab_meta_data=excitation_light_path_0)
excitation_light_paths.append(excitation_light_path_0)

emission_light_paths = list()
emission_light_path_0 = mock_EmissionLightPath(name="EmissionLightPath")
photodetector=mock_Photodetector()
nwbfile.add_device(devices=photodetector)
emission_filter=mock_OpticalFilter()
nwbfile.add_device(devices=emission_filter)
emission_light_path_0 = mock_EmissionLightPath(
name="EmissionLightPath",
photodetector=photodetector,
emission_filter=emission_filter
)
nwbfile.add_lab_meta_data(lab_meta_data=emission_light_path_0)
emission_light_paths.append(emission_light_path_0)

Expand Down Expand Up @@ -248,7 +328,7 @@ def tearDown(self):
pynwb.testing.remove_test_file(self.nwbfile_path)

def test_roundtrip(self):
nwbfile = mock_NWBFile()
nwbfile = mock_NWBFile(session_start_time=datetime(2000, 1, 1, tzinfo=UTC))

microscope = mock_Microscope(name="Microscope")
nwbfile.add_device(devices=microscope)
Expand Down Expand Up @@ -293,7 +373,7 @@ def tearDown(self):
pynwb.testing.remove_test_file(self.nwbfile_path)

def test_roundtrip(self):
nwbfile = mock_NWBFile()
nwbfile = mock_NWBFile(session_start_time=datetime(2000, 1, 1, tzinfo=UTC))

microscope = mock_Microscope(name="Microscope")
nwbfile.add_device(devices=microscope)
Expand Down

0 comments on commit e8ba1bd

Please sign in to comment.