def test_happy_flow_import(self): """ Test that importing a CFF generates at least one DataType in DB. """ ConnectivityZipTest.import_test_connectivity96(self.test_user, self.test_project, subject=TEST_SUBJECT_A) field = FilterChain.datatype + '.subject' filters = FilterChain('', [field], [TEST_SUBJECT_A], ['==']) reference_connectivity = TestFactory.get_entity(self.test_project, Connectivity(), filters) dt_count_before = TestFactory.get_entity_count(self.test_project, Connectivity()) self._import_csv_test_connectivity(reference_connectivity.gid, TEST_SUBJECT_B) dt_count_after = TestFactory.get_entity_count(self.test_project, Connectivity()) self.assertEqual(dt_count_before + 1, dt_count_after) filters = FilterChain('', [field], [TEST_SUBJECT_B], ['like']) imported_connectivity = TestFactory.get_entity(self.test_project, Connectivity(), filters) # check relationship between the imported connectivity and the reference self.assertTrue((reference_connectivity.centres == imported_connectivity.centres).all()) self.assertTrue((reference_connectivity.orientations == imported_connectivity.orientations).all()) self.assertEqual(reference_connectivity.number_of_regions, imported_connectivity.number_of_regions) self.assertTrue((reference_connectivity.region_labels == imported_connectivity.region_labels).all()) self.assertFalse((reference_connectivity.weights == imported_connectivity.weights).all()) self.assertFalse((reference_connectivity.tract_lengths == imported_connectivity.tract_lengths).all())
def test_happy_flow_region_import(self): """ Verifies the happy flow for importing a region. """ dt_count_before = TestFactory.get_entity_count(self.test_project, ProjectionRegionEEG()) group = dao.find_group( 'tvb.adapters.uploaders.projection_matrix_importer', 'ProjectionMatrixRegionEEGImporter') importer = ABCAdapter.build_adapter(group) zip_path = os.path.join( os.path.abspath(os.path.dirname(dataset.__file__)), 'region_conn_74_eeg_1020_62.mat') args = { 'projection_file': zip_path, 'dataset_name': 'ProjectionMatrix', 'connectivity': self.connectivity.gid, 'sensors': self.sensors.gid, DataTypeMetaData.KEY_SUBJECT: DataTypeMetaData.DEFAULT_SUBJECT } FlowService().fire_operation(importer, self.test_user, self.test_project.id, **args) dt_count_after = TestFactory.get_entity_count(self.test_project, ProjectionRegionEEG()) self.assertEqual(dt_count_before + 1, dt_count_after)
def test_happy_flow_surface_import(self): """ Verifies the happy flow for importing a surface. """ dt_count_before = TestFactory.get_entity_count(self.test_project, ProjectionSurfaceEEG()) group = dao.find_group( "tvb.adapters.uploaders.projection_matrix_importer", "ProjectionMatrixSurfaceEEGImporter" ) importer = ABCAdapter.build_adapter(group) file_path = os.path.join( os.path.abspath(os.path.dirname(dataset.__file__)), "projection_eeg_65_surface_16k.npy" ) args = { "projection_file": file_path, "dataset_name": "ProjectionMatrix", "sensors": self.sensors.gid, "surface": self.surface.gid, DataTypeMetaData.KEY_SUBJECT: DataTypeMetaData.DEFAULT_SUBJECT, } FlowService().fire_operation(importer, self.test_user, self.test_project.id, **args) dt_count_after = TestFactory.get_entity_count(self.test_project, ProjectionSurfaceEEG()) self.assertEqual(dt_count_before + 1, dt_count_after)
def test_happy_flow_import(self): """ Test that importing a CFF generates at least one DataType in DB. """ dt_count_before = TestFactory.get_entity_count(self.test_project, Connectivity()) ConnectivityZipTest.import_test_connectivity96(self.test_user, self.test_project) dt_count_after = TestFactory.get_entity_count(self.test_project, Connectivity()) self.assertEqual(dt_count_before + 1, dt_count_after)
def test_happy_flow(self): self.assertEqual( 0, TestFactory.get_entity_count(self.test_project, ConnectivityMeasure())) self._import('mantini_networks.mat') self.assertEqual( 6, TestFactory.get_entity_count(self.test_project, ConnectivityMeasure()))
def test_happy_flow_import(self): """ Test that importing a CFF generates at least one DataType in DB. """ dt_count_before = TestFactory.get_entity_count(self.test_project, Connectivity()) ConnectivityZipTest.import_test_connectivity96(self.test_user, self.test_project) dt_count_after = TestFactory.get_entity_count(self.test_project, Connectivity()) self.assertEqual(dt_count_before + 1, dt_count_after)
def test_happy_flow_surface_import(self): """ Verifies the happy flow for importing a surface. """ dt_count_before = TestFactory.get_entity_count(self.test_project, ProjectionSurfaceEEG()) file_path = os.path.join(os.path.abspath(os.path.dirname(dataset.__file__)), 'projection_eeg_65_surface_16k.npy') args = {'projection_file': file_path, 'dataset_name': 'ProjectionMatrix', 'sensors': self.sensors.gid, 'surface': self.surface.gid, DataTypeMetaData.KEY_SUBJECT: DataTypeMetaData.DEFAULT_SUBJECT} FlowService().fire_operation(self.importer, self.test_user, self.test_project.id, **args) dt_count_after = TestFactory.get_entity_count(self.test_project, ProjectionSurfaceEEG()) self.assertEqual(dt_count_before + 1, dt_count_after)
def test_happy_flow_import(self): """ Test that importing a CFF generates at least one DataType in DB. """ ConnectivityZipTest.import_test_connectivity96(self.test_user, self.test_project, subject=TEST_SUBJECT_A) field = FilterChain.datatype + '.subject' filters = FilterChain('', [field], [TEST_SUBJECT_A], ['==']) reference_connectivity = TestFactory.get_entity( self.test_project, Connectivity(), filters) dt_count_before = TestFactory.get_entity_count(self.test_project, Connectivity()) self._import_csv_test_connectivity(reference_connectivity.gid, TEST_SUBJECT_B) dt_count_after = TestFactory.get_entity_count(self.test_project, Connectivity()) self.assertEqual(dt_count_before + 1, dt_count_after) filters = FilterChain('', [field], [TEST_SUBJECT_B], ['like']) imported_connectivity = TestFactory.get_entity(self.test_project, Connectivity(), filters) # check relationship between the imported connectivity and the reference self.assertTrue( (reference_connectivity.centres == imported_connectivity.centres ).all()) self.assertTrue((reference_connectivity.orientations == imported_connectivity.orientations).all()) self.assertEqual(reference_connectivity.number_of_regions, imported_connectivity.number_of_regions) self.assertTrue((reference_connectivity.region_labels == imported_connectivity.region_labels).all()) self.assertFalse( (reference_connectivity.weights == imported_connectivity.weights ).all()) self.assertFalse((reference_connectivity.tract_lengths == imported_connectivity.tract_lengths).all())
def test_happy_flow_region_import(self): """ Verifies the happy flow for importing a region. """ dt_count_before = TestFactory.get_entity_count(self.test_project, ProjectionRegionEEG()) group = dao.find_group('tvb.adapters.uploaders.projection_matrix_importer', 'ProjectionMatrixRegionEEGImporter') importer = ABCAdapter.build_adapter(group) zip_path = os.path.join(os.path.abspath(os.path.dirname(dataset.__file__)), 'region_conn_74_eeg_1020_62.mat') args = {'projection_file': zip_path, 'dataset_name': 'ProjectionMatrix', 'connectivity': self.connectivity.gid, 'sensors': self.sensors.gid, DataTypeMetaData.KEY_SUBJECT: DataTypeMetaData.DEFAULT_SUBJECT} FlowService().fire_operation(importer, self.test_user, self.test_project.id, **args) dt_count_after = TestFactory.get_entity_count(self.test_project, ProjectionRegionEEG()) self.assertEqual(dt_count_before + 1, dt_count_after)
def test_happy_flow(self): self.assertEqual(0, TestFactory.get_entity_count(self.test_project, ConnectivityMeasure())) self._import('mantini_networks.mat') self.assertEqual(6, TestFactory.get_entity_count(self.test_project, ConnectivityMeasure()))