Esempio n. 1
0
    def test_invalid_storage_path(self):
        """
        This method will test scenarios where no storage path or storage file is provided
        """
        # Test if folder name is None
        with pytest.raises(FileStructureException):
            hdf5.HDF5StorageManager(None, STORAGE_FILE_NAME)

        # Test if file name is None
        with pytest.raises(FileStructureException):
            hdf5.HDF5StorageManager(self.storage_folder, None)
Esempio n. 2
0
 def read_some_data(th_nr):
     global isok
     global exception
     try:
         HDF5_MANAGER = hdf5storage.HDF5StorageManager(ROOT_STORAGE, TEST_FILE_NAME)
         read_data = HDF5_MANAGER.get_data('vertices')
         if read_data.shape != (16000, 3):
             raise Exception("Something went wrong")
         if int(th_nr) > 50000:
             raise Exception("GOT TO 50000 SHOULD STOP NOW")
     except Exception, ex:
         isok = False
         exception = ex.message
Esempio n. 3
0
    def test_concurent_file_access(self):
        """
        This method tests scenario when HDF5 file is opened concurrent for read & write
        """
        new_storage = hdf5.HDF5StorageManager(self.storage_folder, STORAGE_FILE_NAME)
        new_storage.store_data(DATASET_NAME_2, self.test_2D_array)

        for index in range(self.test_3D_array.shape[-1]):
            slices = (slice(None, None, 1), slice(index, index + 1, 1), slice(None, None, 1))
            # Write into file, but leave file open
            self.storage.append_data(DATASET_NAME_1, self.test_3D_array[slices], grow_dimension=1, close_file=False)

            # Now try to read file
            read_data = new_storage.get_data(DATASET_NAME_2)
            self._assert_arrays_are_equal(self.test_2D_array, read_data)
Esempio n. 4
0
    def setup_method(self):
        """
        Set up the context needed by the tests.
        """
        self.storage_folder = os.path.join(TvbProfile.current.TVB_TEMP_FOLDER, "test_hdf5")

        if os.path.exists(self.storage_folder):
            shutil.rmtree(self.storage_folder)
        os.makedirs(self.storage_folder)

        # Now create HDF5 storage instance
        self.storage = hdf5.HDF5StorageManager(self.storage_folder, STORAGE_FILE_NAME)

        self.test_2D_array = numpy.random.random((10, 10))
        self.test_3D_array = numpy.random.random((3, 3, 3))
        self.test_string_array = numpy.array([["a", "b"], ["c", "d"]])
Esempio n. 5
0
 def init_some_data():
     dummy_data = numpy.random.random(size=(16000, 3))
     HDF5_MANAGER = hdf5storage.HDF5StorageManager(ROOT_STORAGE, TEST_FILE_NAME)
     HDF5_MANAGER.store_data('vertices', dummy_data)