Ejemplo n.º 1
0
 def test_open_table(self):
     tid, tcols, meta, ftnames = TableStoreHelper.create_table(
         self.sess, self.ft_space, self.name, [1], "multi", False
     )
     store = OmeroTablesFeatureStore.open_table(self.sess, tid, self.ann_space)
     assert unwrap(store.get_table().getOriginalFile().getId()) == tid
     assert store.ann_space == self.ann_space
     store.close()
 def test_open_table(self):
     tid, tcols, meta, ftnames = TableStoreHelper.create_table(
         self.sess, self.ft_space, self.name, [1], 'multi', False)
     store = OmeroTablesFeatureStore.open_table(
         self.sess, tid, self.ann_space)
     assert unwrap(store.get_table().getOriginalFile().getId()) == tid
     assert store.ann_space == self.ann_space
     store.close()
    def test_get(self, state):
        ownerid = 123
        session = MockSession(None, None, ownerid)
        fs = MockFeatureTable(session)
        fs.table = object()
        self.mox.StubOutWithMock(OmeroTablesFeatureStore, 'list_tables')
        self.mox.StubOutWithMock(OmeroTablesFeatureStore, 'open_table')
        fsname = 'fsname'
        fts = OmeroTablesFeatureStore.FeatureTableManager(session,
                                                          namespace='x')

        self.mox.StubOutWithMock(fts.fss, 'get')
        self.mox.StubOutWithMock(fts.fss, 'insert')

        k = (fsname, ownerid)

        if state == 'opened':
            fts.fss.get(k).AndReturn(fs)
        else:
            if state == 'unopened':
                fts.fss.get(k).AndReturn(None)
            if state == 'closed':
                fsold = MockFeatureTable(None)
                fts.fss.get(k).AndReturn(fsold)

            r = (1234, None, None, None)
            OmeroTablesFeatureStore.list_tables(session,
                                                fsname,
                                                'x/features',
                                                ownerid=ownerid).AndReturn([r])
            OmeroTablesFeatureStore.open_table(session, r[0],
                                               'x/source').AndReturn(fs)
            fts.fss.insert(k, fs)

        self.mox.ReplayAll()

        assert fts.get(fsname, ownerid) == fs
        self.mox.VerifyAll()
Ejemplo n.º 4
0
    def test_get(self, state):
        ownerid = 123
        session = MockSession(None, None, ownerid)
        fs = MockFeatureTable(session)
        fs.table = object()
        self.mox.StubOutWithMock(OmeroTablesFeatureStore, 'list_tables')
        self.mox.StubOutWithMock(OmeroTablesFeatureStore, 'open_table')
        fsname = 'fsname'
        fts = OmeroTablesFeatureStore.FeatureTableManager(
            session, namespace='x')

        self.mox.StubOutWithMock(fts.fss, 'get')
        self.mox.StubOutWithMock(fts.fss, 'insert')

        k = (fsname, ownerid)

        if state == 'opened':
            fts.fss.get(k).AndReturn(fs)
        else:
            if state == 'unopened':
                fts.fss.get(k).AndReturn(None)
            if state == 'closed':
                fsold = MockFeatureTable(None)
                fts.fss.get(k).AndReturn(fsold)

            r = (1234, None, None, None)
            OmeroTablesFeatureStore.list_tables(
                session, fsname, 'x/features', ownerid=ownerid).AndReturn([r])
            OmeroTablesFeatureStore.open_table(
                session, r[0], 'x/source').AndReturn(fs)
            fts.fss.insert(k, fs)

        self.mox.ReplayAll()

        assert fts.get(fsname, ownerid) == fs
        self.mox.VerifyAll()