예제 #1
0
class Limbo_internalPutGet(StoreDependentTestCase):
    def setUp(self):
        super(Limbo_internalPutGet, self).setUp()
        self.limbo = Limbo()

    def test_put(self):
        id = self.limbo.random_ObjectID(1)
        self.limbo._put(1, id[0])
        self.assertEqual(1, self.limbo.client.get(id[0]))

    def test_get(self):
        id = self.limbo.put(1, 'one')
        self.limbo.updateStored('one', id)
        self.assertEqual(self.limbo._get('one'), 1)

    def test__getNonexistent(self):

        # Handle exception thrown
        with self.assertRaises(Exception) as cm:
            # Check that the exception thrown is a ObjectNotFoundError
            self.limbo._get('three')
            self.assertEqual(cm.exception.name, 'ObjectNotFoundError')
            self.assertEqual(cm.exception.message,
                             'Cannnot find object with ID/name "three"')

    def tearDown(self):
        super(Limbo_internalPutGet, self).tearDown()
예제 #2
0
class Limbo_UpdateStored(StoreDependentTestCase):
    def setUp(self):
        super(Limbo_UpdateStored, self).setUp()
        self.limbo = Limbo()

    # Accessing self.limbo.stored directly to test getStored separately
    def test_updateGet(self):
        self.limbo.put(1, 'one')
        self.limbo.updateStored('one', 3)
        self.assertEqual(3, self.limbo.stored['one'])

    def tearDown(self):
        super(Limbo_UpdateStored, self).tearDown()
예제 #3
0
class Limbo_sparseMatrix(StoreDependentTestCase):
    def setUp(self):
        super(Limbo_sparseMatrix, self).setUp()
        self.limbo = Limbo()

    def test_csc(self):
        csc = csc_matrix((3, 4), dtype=np.int8)
        self.limbo.put(csc, "csc")
        self.assertTrue(
            np.allclose(self.limbo.get("csc").toarray(), csc.toarray()))

    def tearDown(self):
        super(Limbo_sparseMatrix, self).tearDown()
예제 #4
0
class Limbo_getListandAll(StoreDependentTestCase):
    def setUp(self):
        super(Limbo_getListandAll, self).setUp()
        self.limbo = Limbo()

    def getListandAll(self):
        id = self.limbo.put(1, 'one')
        id2 = self.limbo.put(2, 'two')
        id3 = self.limbo.put(3, 'three')
        self.assertEqual([1, 2], self.limbo.getList(['one', 'two']))
        self.assertEqual([1, 2, 3], self.limbo.get_all())

    def tearDown(self):
        super(Limbo_getListandAll, self).tearDown()
예제 #5
0
class Limbo_GetStored(StoreDependentTestCase):
    def setUp(self):
        super(Limbo_GetStored, self).setUp()
        self.limbo = Limbo()

    def test_getStoredEmpty(self):
        self.assertFalse(self.limbo.getStored())

    def test_putGetStored(self):
        self.limbo.put(1, 'one')
        self.assertEqual(1, self.limbo.getID(
            self.limbo.getStored()['one']))  # returns ID

    def tearDown(self):
        super(Limbo_GetStored, self).tearDown()
예제 #6
0
class Acquirer_Setup(StoreDependentTestCase):
    ''' Test creation of FileAcquirer object and store connection
        along with various components
    '''

    def setUp(self):
        super(Acquirer_Setup, self).setUp()
        self.limbo = Limbo()
        self.acq = FileAcquirer('acq', self.limbo)
        self.acq.setupAcquirer('/Users/hawkwings/Documents/Neuro/RASP/rasp/data/Tolias_mesoscope_1.hdf5')

    # def test_init(self):
    #     #self.acq.setupAcquirer('/Users/hawkwings/Documents/Neuro/RASP/rasp/data/zf1.h5')
    #     self.assertTrue(1)
    
    def test_frame_acq(self):
        #self.acq.setupAcquirer('/Users/hawkwings/Documents/Neuro/RASP/rasp/data/zf1.h5')
        frame = self.acq.getFrame(1)
        print(frame.shape)
        self.assertTrue(frame.shape==(440,256))

    def test_store_frame(self):
        for _ in range(1010):
            self.acq.runAcquirer()
        frame = self.limbo.get('curr_frame')
        self.assertTrue(frame.shape==(440,256))

    def tearDown(self):
        super(Acquirer_Setup, self).tearDown()
예제 #7
0
class Limbo_saveTweak(StoreDependentTestCase):
    def setUp(self):
        super(Limbo_saveTweak, self).setUp()
        self.limbo = Limbo()

    def test_tweak(self):
        fileName = 'data/tweak_dump'
        id = self.limbo.put(1, 'one')
        id2 = self.limbo.put(2, 'two')
        tweak_ids = [id, id2]
        self.limbo.saveTweak(tweak_ids)
        with open(fileName, 'rb') as output:
            self.assertEqual(pickle.load(output), [1, 2])

    def tearDown(self):
        super(Limbo_saveTweak, self).tearDown()
예제 #8
0
class Limbo_Put(StoreDependentTestCase):
    def setUp(self):
        super(Limbo_Put, self).setUp()
        self.limbo = Limbo()

    def test_putOne(self):
        id = self.limbo.put(1, 'one')
        self.assertEqual(1, self.limbo.get('one'))

    def test_put_twice(self):
        id = self.limbo.put(2, 'two')
        id2 = self.limbo.put(2, 'two')
        self.assertRaises(PlasmaObjectExists)

    def tearDown(self):
        super(Limbo_Put, self).tearDown()
예제 #9
0
class Limbo_Get(StoreDependentTestCase):
    def setUp(self):
        super(Limbo_Get, self).setUp()
        self.limbo = Limbo()

    def test_init_empty(self):
        self.assertFalse(self.limbo.get_all())

    def tearDown(self):
        super(Limbo_Get, self).tearDown()
예제 #10
0
class Limbo_ReleaseReset(StoreDependentTestCase):
    def setUp(self):
        super(Limbo_ReleaseReset, self).setUp()
        self.limbo = Limbo()

    def test_release(self):
        self.limbo.release()
        self.limbo.put(1, 'one')
        self.assertRaises(ArrowIOError)

    def test_reset(self):
        self.limbo.reset()
        self.limbo.put(1, 'one')
        self.assertEqual(self.limbo.get('one'), 1)

    def tearDown(self):
        super(Limbo_ReleaseReset, self).tearDown()
예제 #11
0
class Limbo_Connect(StoreDependentTestCase):
    def setUp(self):
        super(Limbo_Connect, self).setUp()
        self.limbo = Limbo()

    def test_Connect(self):
        store_loc = '/tmp/store'
        self.limbo.connectStore(store_loc)
        self.assertIsInstance(self.limbo.client, plasma.PlasmaClient)

    def test_failToConnect(self):
        store_loc = 'asdf'

        # Handle exception thrown
        with self.assertRaises(Exception) as cm:
            self.limbo.connectStore(store_loc)

        # Check that the exception thrown is a CannotConnectToStoreError
        self.assertEqual(cm.exception.name, 'CannotConnectToStoreError')

    def tearDown(self):
        super(Limbo_Connect, self).tearDown()
예제 #12
0
class Limbo_PutGet(StoreDependentTestCase):
    def setUp(self):
        super(Limbo_PutGet, self).setUp()
        self.limbo = Limbo()

    def test_getOne(self):
        id = self.limbo.put(1, 'one')
        id2 = self.limbo.put(2, 'two')
        self.assertEqual(1, self.limbo.get('one'))
        self.assertEqual(id, self.limbo.stored['one'])

    def test_get_nonexistent(self):

        # Handle exception thrown
        with self.assertRaises(Exception) as cm:
            self.limbo.get('three')

        # Check that the exception thrown is a CannotGetObjectError
        self.assertEqual(cm.exception.name, 'CannotGetObjectError')

    def tearDown(self):
        super(Limbo_PutGet, self).tearDown()
예제 #13
0
class Limbo_GetID(StoreDependentTestCase):
    #Check both hdd_only=False/True
    #Check isInstance type, isInstance bytes, else

    def setUp(self):
        super(Limbo_GetID, self).setUp()
        self.limbo = Limbo()

    def test_isMatrix(self):  #also tests put matrix
        mat = csc_matrix((3, 4), dtype=np.int8)
        x = self.limbo.put(mat, 'matrix')  #returns object_id
        self.assertIsInstance(self.limbo.getID(x), csc_matrix)

    def test_notPut(self):
        obj = self.limbo.getID(self.limbo.random_ObjectID(1))
        self.assertRaises(ObjectNotFoundError)

    def UseHDD(self):
        self.lmdb_store.put(1, 'one')
        assertEqual(self.lmdb_store.getID('one', hdd_only=True), 1)

    def tearDown(self):
        super(Limbo_GetID, self).tearDown()
예제 #14
0
class Caiman_Setup(StoreDependentTestCase):
    ''' Test creation of OnACID object and store connection
    '''
    def setUp(self):
        super(Caiman_Setup, self).setUp()
        self.limbo = Limbo()
        self.proc = cp()
        self.proc.setStore(self.limbo)

    def test_StartProc(self):
        #cp.setupProcess(self.proc, 'params_dict')
        self.assertTrue(1)

    def test_runProc(self):
        self.proc.setup()
        fnames = self.limbo.get('params_dict')['fnames']
        print('Test runProc: processing files: ', fnames)
        t = time.time()
        self.proc.runProcess()
        print('time is ', time.time() - t)
        self.assertTrue(1)

    def tearDown(self):
        super(Caiman_Setup, self).tearDown()
예제 #15
0
 def setUp(self):
     super(Limbo_UpdateStored, self).setUp()
     self.limbo = Limbo()
예제 #16
0
 def setUp(self):
     super(Acquirer_Setup, self).setUp()
     self.limbo = Limbo()
     self.acq = FileAcquirer('acq', self.limbo)
     self.acq.setupAcquirer('/Users/hawkwings/Documents/Neuro/RASP/rasp/data/Tolias_mesoscope_1.hdf5')
예제 #17
0
 def setUp(self):
     super(Actor_setStore, self).setUp()
     self.actor = Actor('test')
     self.limbo = Limbo()
예제 #18
0
 def setUp(self):
     super(Caiman_Setup, self).setUp()
     self.limbo = Limbo()
     self.proc = cp()
     self.proc.setStore(self.limbo)
예제 #19
0
 def setUp(self):
     super(Limbo_GetStored, self).setUp()
     self.limbo = Limbo()
예제 #20
0
 def setUp(self):
     super(Limbo_ReleaseReset, self).setUp()
     self.limbo = Limbo()
예제 #21
0
 def setUp(self):
     super(Limbo_PutGet, self).setUp()
     self.limbo = Limbo()
예제 #22
0
 def setUp(self):
     super(Limbo_getListandAll, self).setUp()
     self.limbo = Limbo()
예제 #23
0
 def setUp(self):
     super(Limbo_GetID, self).setUp()
     self.limbo = Limbo()
예제 #24
0
 def setUp(self):
     super(Limbo_Connect, self).setUp()
     self.limbo = Limbo()
예제 #25
0
 def setUp(self):
     super(Limbo_internalPutGet, self).setUp()
     self.limbo = Limbo()
예제 #26
0
 def setUp(self):
     super(Limbo_sparseMatrix, self).setUp()
     self.limbo = Limbo()
예제 #27
0
 def setUp(self):
     super(Limbo_saveTweak, self).setUp()
     self.limbo = Limbo()