Exemple #1
0
    def test_inmemorydatastore_single_value(self):
        ## WRITE
        inmem_datastore = InMemoryDataStore()
        recorder = Recorder(inmem_datastore)

        recorder.set(self.key, self.val1)
        recorder.set(self.key, self.val)
        recorder.close()
        ## END WRITE

        ## READ
        # If the in-memory datastore is initialized, all data will be reset!
        recorder = Recorder(inmem_datastore)

        l = recorder.get(self.key)
        l = np.array(l)
        self.assertTrue((self.val == l).all())

        recorder.close()
Exemple #2
0
    def test_hdf5datastore_single_value(self):
        ## WRITE
        self.file_pth = os.path.join(self.data_dir, 'data.h5')
        hdf5_datastore = HDF5DataStore(self.file_pth)
        recorder = Recorder(hdf5_datastore)
        recorder.set(self.key, self.val1)
        recorder.set(self.key, self.val)
        recorder.close()
        ## END WRITE

        ## READ
        hdf5_datastore = HDF5DataStore(self.file_pth)
        recorder = Recorder(hdf5_datastore)

        l = recorder.get(self.key)
        l = np.array(l)
        self.assertTrue((self.val == l).all())

        recorder.close()
    def test_zarrdatastore_single_value(self):
        ## WRITE
        assert not os.path.exists(os.path.join(self.data_dir, 'test.mdb'))
        zarr_datastore = ZarrDataStore(os.path.join(self.data_dir, 'test.mdb'))
        recorder = Recorder(zarr_datastore)

        recorder.set(self.key, self.val1)
        recorder.set(self.key, self.val)
        recorder.close()
        ## END WRITE

        ## READ
        zarr_datastore = ZarrDataStore(os.path.join(self.data_dir, 'test.mdb'))
        recorder = Recorder(zarr_datastore)

        l = recorder.get(self.key)
        l = np.array(l)
        self.assertTrue((self.val == l).all())

        recorder.close()
Exemple #4
0
    def test_redisdatastore_single_value(self):
        with RedisServer(data_directory=self.data_dir):
            ## WRITE
            redis_datastore = RedisDataStore(server_host='localhost')
            recorder = Recorder(redis_datastore)

            recorder.set(self.key, self.val1)
            recorder.set(self.key, self.val)
            recorder.close()
            ## END WRITE

        with RedisServer(data_directory=self.data_dir):
            ## READ
            redis_datastore = RedisDataStore(server_host='localhost')
            recorder = Recorder(redis_datastore)

            l = recorder.get(self.key)
            l = np.array(l)
            self.assertTrue((self.val == l).all())

            recorder.close()