Skip to content

Commit

Permalink
ndx_extensions tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksandercwikla committed Feb 13, 2020
1 parent 2a80ebd commit c8f17c4
Show file tree
Hide file tree
Showing 11 changed files with 402 additions and 6 deletions.
14 changes: 14 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Copyright 2020, NovelaNeurotechnologies

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
64 changes: 64 additions & 0 deletions spec/ndx-novela-namespace.extensions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,67 @@ groups:
shape:
- 2
doc: names of the nodes this edge connects
- neurodata_type_def: HeaderDevice
neurodata_type_inc: Device
doc: metadata from global configuration from header
attributes:
- name: headstage_serial
dtype: text
doc: headstage_serial from global configuration
- name: headstage_smart_ref_on
dtype: text
doc: headstage_smart_ref_on from global configuration
- name: realtime_mode
dtype: text
doc: realtime_mode from global configuration
- name: headstage_auto_settle_on
dtype: text
doc: headstage_auto_settle_on from global configuration
- name: timestamp_at_creation
dtype: text
doc: timestamp_at_creation from global configuration
- name: controller_firmware_version
dtype: text
doc: conntroller_firmware_version from global configuration
- name: controller_serial
dtype: text
doc: controller_serial from global configuration
- name: save_displayed_chan_only
dtype: text
doc: save_displayed_chan_only from global configuration
- name: headstage_firmware_version
dtype: text
doc: headstage_firmware_version from global configuration
- name: qt_version
dtype: text
doc: qt_version_version from global configuration
- name: compile_date
dtype: text
doc: compile_date_version from global configuration
- name: compile_time
dtype: text
doc: compile_time_version from global configuration
- name: file_prefixn
dtype: text
doc: file_prefix_version from global configuration
- name: headstage_gyro_sensor_on
dtype: text
doc: headstage_gyro_sensor_on_version from global configuration
- name: headstage_mag_sensor_on
dtype: text
doc: headstage_mag_sensor_on_version from global configuration
- name: trodes_version
dtype: text
doc: trodes_versionversion from global configuration
- name: headstage_accel_sensor_on
dtype: text
doc: headstage_accel_sensor_on from global configuration
- name: commit_head
dtype: text
doc: commit_head from global configuration
- name: system_time_at_creation
dtype: text
doc: system_time_at_creation from global configuration
- name: file_path
dtype: text
doc: file_path from global configuration
Empty file added src/__init__.py
Empty file.
Empty file added src/pynwb/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions src/pynwb/ndx_novela_namespace/apparatus.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
from pynwb import register_class
from pynwb.core import MultiContainerInterface

from src.pynwb.ndx_novela_namespace.edge import Edge
from src.pynwb.ndx_novela_namespace.node import Node


@register_class('Apparatus', 'ndx-novela-namespace')
class Apparatus(MultiContainerInterface):
Expand Down
4 changes: 1 addition & 3 deletions src/pynwb/ndx_novela_namespace/header_device.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import os

from hdmf.utils import docval, call_docval_func, get_docval
from pynwb import register_class, load_namespaces
from pynwb import register_class
from pynwb.device import Device


Expand Down
45 changes: 45 additions & 0 deletions src/pynwb/tests/test_apparatus.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
from unittest import TestCase
from unittest.mock import Mock

from src.pynwb.ndx_novela_namespace.apparatus import Apparatus
from src.pynwb.ndx_novela_namespace.edge import Edge
from src.pynwb.ndx_novela_namespace.node import Node


class TestApparatus(TestCase):
@classmethod
def setUpClass(cls):
cls.node_1 = Mock()
cls.node_1.__class__ = Node
cls.node_2 = Mock()
cls.node_2.__class__ = Node

cls.node_3 = Mock()
cls.node_3.__class__ = Node
cls.node_4 = Mock()
cls.node_4.__class__ = Node

cls.edge_1 = Mock()
cls.edge_1.__class__ = Edge
cls.edge_2 = Mock()
cls.edge_2.__class__ = Edge

cls.apparatus = Apparatus(
name='ApparatusName',
edges=[cls.edge_1, cls.edge_2],
nodes=[cls.node_1, cls.node_2, cls.node_3, cls.node_4]
)

def test_successfulEdgeCreation_true(self):
self.assertIsInstance(self.apparatus, Apparatus)

def test_checkEdgeCorrectValue_true(self):
self.assertEqual(self.apparatus.name, 'ApparatusName')
self.assertEqual(self.apparatus.edges, {self.edge_1.name: self.edge_1, self.edge_2.name: self.edge_2})
self.assertEqual(self.apparatus.nodes, {self.node_1.name: self.node_1, self.node_2.name: self.node_2,
self.node_3.name: self.node_3, self.node_4.name: self.node_4})

def test_checkEdgeCorrectType_true(self):
self.assertIsInstance(self.apparatus.name, str)
self.assertIsInstance(self.apparatus.edges, dict)
self.assertIsInstance(self.apparatus.nodes, dict)
39 changes: 39 additions & 0 deletions src/pynwb/tests/test_fl_electrode_group.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import unittest
from unittest.mock import Mock

from pynwb.device import Device

from src.pynwb.ndx_novela_namespace.fl_electrode_group import FLElectrodeGroup


class TestFLElectrodeGroup(unittest.TestCase):

@classmethod
def setUpClass(cls):
cls.mock_device = Mock()
cls.mock_device.__class__ = Device

cls.fl_electrode_group = FLElectrodeGroup(
name='FLElectrodeGroup1',
id=1,
description='Sample description',
location='Sample location',
device=cls.mock_device,
)

def test_successfulNodeCreation_true(self):
self.assertIsInstance(self.fl_electrode_group, FLElectrodeGroup)

def test_checkNodeCorrectValue_true(self):
self.assertEqual(self.fl_electrode_group.name, 'FLElectrodeGroup1')
self.assertEqual(self.fl_electrode_group.description, 'Sample description')
self.assertEqual(self.fl_electrode_group.location, 'Sample location')
self.assertEqual(self.fl_electrode_group.device, self.mock_device)
self.assertEqual(self.fl_electrode_group.id, 1)

def test_checkNodeCorrectType_true(self):
self.assertIsInstance(self.fl_electrode_group.name, str)
self.assertIsInstance(self.fl_electrode_group.description, str)
self.assertIsInstance(self.fl_electrode_group.location, str)
self.assertIsInstance(self.fl_electrode_group.device, Device)
self.assertIsInstance(self.fl_electrode_group.id, int)
81 changes: 81 additions & 0 deletions src/pynwb/tests/test_header_device.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
from unittest import TestCase

from src.pynwb.ndx_novela_namespace.header_device import HeaderDevice


class TestHeaderDevice(TestCase):

@classmethod
def setUpClass(cls):
cls.header_device = HeaderDevice(
name='HeaderDevice1',
headstage_serial='Sample headstage_serial',
headstage_smart_ref_on='Sample headstage_smart_ref_on',
realtime_mode='Sample realtime_mode',
headstage_auto_settle_on='Sample headstage_auto_settle_on',
timestamp_at_creation='Sample timestamp_at_creation',
controller_firmware_version='Sample controller_firmware_version',
controller_serial='Sample controller_serial',
save_displayed_chan_only='Sample save_displayed_chan_only',
headstage_firmware_version='Sample headstage_firmware_version',
qt_version='Sample qt_version',
compile_date='Sample compile_date',
compile_time='Sample compile_time',
file_prefix='Sample file_prefix',
headstage_gyro_sensor_on='Sample headstage_gyro_sensor_on',
headstage_mag_sensor_on='Sample headstage_mag_sensor_on',
trodes_version='Sample trodes_version',
headstage_accel_sensor_on='Sample headstage_accel_sensor_on',
commit_head='Sample commit_head',
system_time_at_creation='Sample system_time_at_creation',
file_path='Sample file_path',
)

def test_successfulNodeCreation_true(self):
self.assertIsInstance(self.header_device, HeaderDevice)

def test_checkNodeCorrectValue_true(self):
self.assertEqual(self.header_device.name, 'HeaderDevice1')
self.assertEqual(self.header_device.headstage_serial, 'Sample headstage_serial')
self.assertEqual(self.header_device.headstage_smart_ref_on, 'Sample headstage_smart_ref_on')
self.assertEqual(self.header_device.realtime_mode, 'Sample realtime_mode')
self.assertEqual(self.header_device.headstage_auto_settle_on, 'Sample headstage_auto_settle_on')
self.assertEqual(self.header_device.timestamp_at_creation, 'Sample timestamp_at_creation')
self.assertEqual(self.header_device.controller_firmware_version, 'Sample controller_firmware_version')
self.assertEqual(self.header_device.controller_serial, 'Sample controller_serial')
self.assertEqual(self.header_device.save_displayed_chan_only, 'Sample save_displayed_chan_only')
self.assertEqual(self.header_device.headstage_firmware_version, 'Sample headstage_firmware_version')
self.assertEqual(self.header_device.qt_version, 'Sample qt_version')
self.assertEqual(self.header_device.compile_date, 'Sample compile_date')
self.assertEqual(self.header_device.compile_time, 'Sample compile_time')
self.assertEqual(self.header_device.file_prefix, 'Sample file_prefix')
self.assertEqual(self.header_device.headstage_gyro_sensor_on, 'Sample headstage_gyro_sensor_on')
self.assertEqual(self.header_device.headstage_mag_sensor_on, 'Sample headstage_mag_sensor_on')
self.assertEqual(self.header_device.trodes_version, 'Sample trodes_version')
self.assertEqual(self.header_device.headstage_accel_sensor_on, 'Sample headstage_accel_sensor_on')
self.assertEqual(self.header_device.commit_head, 'Sample commit_head')
self.assertEqual(self.header_device.system_time_at_creation, 'Sample system_time_at_creation')
self.assertEqual(self.header_device.file_path, 'Sample file_path')

def test_checkNodeCorrectType_true(self):
self.assertEqual(self.header_device.name, 'HeaderDevice1')
self.assertIsInstance(self.header_device.headstage_serial, str)
self.assertIsInstance(self.header_device.headstage_smart_ref_on, str)
self.assertIsInstance(self.header_device.realtime_mode, str)
self.assertIsInstance(self.header_device.headstage_auto_settle_on, str)
self.assertIsInstance(self.header_device.timestamp_at_creation, str)
self.assertIsInstance(self.header_device.controller_firmware_version, str)
self.assertIsInstance(self.header_device.controller_serial, str)
self.assertIsInstance(self.header_device.save_displayed_chan_only, str)
self.assertIsInstance(self.header_device.headstage_firmware_version, str)
self.assertIsInstance(self.header_device.qt_version, str)
self.assertIsInstance(self.header_device.compile_date, str)
self.assertIsInstance(self.header_device.compile_time, str)
self.assertIsInstance(self.header_device.file_prefix, str)
self.assertIsInstance(self.header_device.headstage_gyro_sensor_on, str)
self.assertIsInstance(self.header_device.headstage_mag_sensor_on, str)
self.assertIsInstance(self.header_device.trodes_version, str)
self.assertIsInstance(self.header_device.headstage_accel_sensor_on, str)
self.assertIsInstance(self.header_device.commit_head, str)
self.assertIsInstance(self.header_device.system_time_at_creation, str)
self.assertIsInstance(self.header_device.file_path, str)
45 changes: 45 additions & 0 deletions src/pynwb/tests/test_ntrode.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import unittest
from unittest.mock import Mock

from pynwb.device import Device

from src.pynwb.ndx_novela_namespace.ntrode import NTrode


class TestNTrode(unittest.TestCase):

@classmethod
def setUpClass(cls):
cls.mock_device = Mock()
cls.mock_device.__class__ = Device

cls.ntrode = NTrode(
name='NTrode1',
description='Sample description',
location='Sample location',
device=cls.mock_device,
ntrode_id=1,
probe_id=1,
map=[[1, 2], [3, 4], [5, 6]]
)

def test_successfulNodeCreation_true(self):
self.assertIsInstance(self.ntrode, NTrode)

def test_checkNodeCorrectValue_true(self):
self.assertEqual(self.ntrode.name, 'NTrode1')
self.assertEqual(self.ntrode.description, 'Sample description')
self.assertEqual(self.ntrode.location, 'Sample location')
self.assertEqual(self.ntrode.device, self.mock_device)
self.assertEqual(self.ntrode.ntrode_id, 1)
self.assertEqual(self.ntrode.probe_id, 1)
self.assertEqual(self.ntrode.map, [[1, 2], [3, 4], [5, 6]])

def test_checkNodeCorrectType_true(self):
self.assertIsInstance(self.ntrode.name, str)
self.assertIsInstance(self.ntrode.description, str)
self.assertIsInstance(self.ntrode.location, str)
self.assertIsInstance(self.ntrode.device, Device)
self.assertIsInstance(self.ntrode.ntrode_id, int)
self.assertIsInstance(self.ntrode.probe_id, int)
self.assertIsInstance(self.ntrode.map, list)
Loading

0 comments on commit c8f17c4

Please sign in to comment.