def test_annotateAndAnnotated(self): # There's a bug somewhere which means annotating the table with the # version annotation, then using the table as a FileAnnotation on # an object, causes the version annotation to be lost # Closing and reopening the table seems to work (see # FeatureTable.createTable) cli, sess = self.create_client() ft = FeatureTable(client=cli, tableName=self.tableName) fts = ['a [0]', 'a [1]', 'b [0]'] ft.createTable(fts, version=self.version) tid = ft.tc.tableId self.assertEqual(self.version, unwrapVersion(ft.versiontag)) vertag = WndcharmStorage.getVersion(ft.conn, 'OriginalFile', tid) self.assertEqual(self.version, unwrapVersion(vertag)) p = omero.model.ProjectI() p.setName(wrap('tmp')) p = self.sess.getUpdateService().saveAndReturnObject(p) pid = unwrap(p.getId()) p = ft.conn.getObject('Project', pid) WndcharmStorage.addFileAnnotationTo(ft.tc, p) vertag = WndcharmStorage.getVersion(ft.conn, 'OriginalFile', tid) self.assertEqual(self.version, unwrapVersion(vertag)) self.delete('/Project', pid) self.delete('/OriginalFile', tid)
def test_getAttachedTableFile(self): pid = self.create_project('addFileAnnotationTo') p = self.conn.getObject('Project', pid) tc = self.Tc(self.conn) fid = unwrap(tc.table.getOriginalFile().getId()) self.assertIsNone(WndcharmStorage.getAttachedTableFile(tc, p)) WndcharmStorage.addFileAnnotationTo(tc, p) self.assertIsNotNone(WndcharmStorage.getAttachedTableFile(tc, p)) tc.close() self.delete('/Project', pid)
def test_addFileAnnotationTo(self): pid = self.create_project('addFileAnnotationTo') p = self.conn.getObject('Project', pid) tc = self.Tc(self.conn) fid = unwrap(tc.table.getOriginalFile().getId()) WndcharmStorage.addFileAnnotationTo(tc, p) proj = self.conn.getObject('Project', pid) a = proj.getAnnotation() self.assertIsInstance(a._obj, omero.model.FileAnnotation) self.assertEqual(unwrap(a.getFile().getId()), fid) tc.close() self.delete('/Project', pid)