예제 #1
0
 def testClearSet(self):
     img = ImageI()
     assert img.sizeOfPixels() >= 0
     img.addPixels(PixelsI())
     assert 1 == img.sizeOfPixels()
     img.clearPixels()
     assert img.sizeOfPixels() >= 0
     assert 0 == img.sizeOfPixels()
예제 #2
0
 def testClearSet(self):
     img = ImageI()
     self.assert_(img.sizeOfPixels() >= 0)
     img.addPixels(PixelsI())
     self.assert_(1 == img.sizeOfPixels())
     img.clearPixels()
     self.assert_(img.sizeOfPixels() >= 0)
     self.assert_(0 == img.sizeOfPixels())
예제 #3
0
 def testUnloadedCtor(self):
     img = ImageI(rlong(1), False)
     assert not img.isLoaded()
     try:
         assert img.sizeOfDatasetLinks() < 0
         assert False, "Should throw"
     except:
         # Is true, but can't test it.
         pass
예제 #4
0
 def testIterators(self):
     d = DatasetI()
     image = ImageI()
     image.linkDataset(d)
     it = image.iterateDatasetLinks()
     count = 0
     for i in it:
         count += 1
     self.assert_(count == 1)
예제 #5
0
 def testUnloadedCtor(self):
     img = ImageI(rlong(1),False)
     self.assert_( not img.isLoaded() )
     try:
         self.assert_( img.sizeOfDatasetLinks() < 0 )
         self.fail("Should throw")
     except:
         # Is true, but can't test it.
         pass
예제 #6
0
 def testIterators(self):
     d = DatasetI()
     image = ImageI()
     image.linkDataset(d)
     it = image.iterateDatasetLinks()
     count = 0
     for i in it:
         count += 1
     assert count == 1
예제 #7
0
 def testUnloadedCtor(self):
     img = ImageI(rlong(1), False)
     self.assert_(not img.isLoaded())
     try:
         self.assert_(img.sizeOfDatasetLinks() < 0)
         self.fail("Should throw")
     except:
         # Is true, but can't test it.
         pass
예제 #8
0
 def testUnloadedCtor(self):
     img = ImageI(rlong(1), False)
     assert not img.isLoaded()
     try:
         assert img.sizeOfDatasetLinks() < 0
         assert False, "Should throw"
     except:
         # Is true, but can't test it.
         pass
예제 #9
0
 def testUnloadSet(self):
     img = ImageI()
     assert img.sizeOfPixels() >= 0
     img.addPixels(PixelsI())
     assert 1 == img.sizeOfPixels()
     img.unloadPixels()
     assert img.sizeOfPixels() < 0
예제 #10
0
 def testUnloadSet(self):
     img = ImageI()
     self.assert_(img.sizeOfPixels() >= 0)
     img.addPixels(PixelsI())
     self.assert_(1 == img.sizeOfPixels())
     img.unloadPixels()
     self.assert_(img.sizeOfPixels() < 0)
예제 #11
0
 def testGetAttrGood(self):
     i = ImageI()
     assert i.loaded
     assert i.isLoaded()
     assert not i.name
     i.name = rstring("name")
     assert i.name
     i.setName(None)
     assert not i.getName()
     i.copyAnnotationLinks()
     i.linkAnnotation(omero.model.BooleanAnnotationI())
예제 #12
0
 def testClearSet(self):
     img = ImageI()
     self.assert_( img.sizeOfPixels() >= 0 )
     img.addPixels( PixelsI() )
     self.assert_( 1==img.sizeOfPixels() )
     img.clearPixels()
     self.assert_( img.sizeOfPixels() >= 0 )
     self.assert_( 0==img.sizeOfPixels() )
예제 #13
0
 def testClearSet(self):
     img = ImageI()
     assert img.sizeOfPixels() >= 0
     img.addPixels(PixelsI())
     assert 1 == img.sizeOfPixels()
     img.clearPixels()
     assert img.sizeOfPixels() >= 0
     assert 0 == img.sizeOfPixels()
예제 #14
0
    def testRemoveFromSet(self):
        pix = PixelsI()
        img = ImageI()
        self.assert_(img.sizeOfPixels() >= 0)

        img.addPixels(pix)
        self.assert_(1 == img.sizeOfPixels())

        img.removePixels(pix)
        self.assert_(0 == img.sizeOfPixels())
예제 #15
0
    def testRemoveFromSet(self):
        pix = PixelsI()
        img = ImageI()
        assert img.sizeOfPixels() >= 0

        img.addPixels(pix)
        assert 1 == img.sizeOfPixels()

        img.removePixels(pix)
        assert 0 == img.sizeOfPixels()
예제 #16
0
 def testGetAttrBad(self):
    i = ImageI()
    def assign_loaded():
         i.loaded = False
    self.assertRaises( AttributeError, assign_loaded )
    self.assertRaises( AttributeError, lambda: i.foo )
    def assign_foo():
         i.foo = 1
    self.assertRaises( AttributeError, assign_foo )
    self.assertRaises( AttributeError, lambda: i.annotationLinks )
    self.assertRaises( AttributeError, lambda: i.getAnnotationLinks() )
    def assign_links():
         i.annotationLinks = []
    self.assertRaises( AttributeError, assign_links)
예제 #17
0
 def testGetAttrBad(self):
    i = ImageI()
    def assign_loaded():
         i.loaded = False
    pytest.raises( AttributeError, assign_loaded )
    pytest.raises( AttributeError, lambda: i.foo )
    def assign_foo():
         i.foo = 1
    pytest.raises( AttributeError, assign_foo )
    pytest.raises( AttributeError, lambda: i.annotationLinks )
    pytest.raises( AttributeError, lambda: i.getAnnotationLinks() )
    def assign_links():
         i.annotationLinks = []
    pytest.raises( AttributeError, assign_links)
예제 #18
0
 def testUnloadSet(self):
     img = ImageI()
     self.assert_( img.sizeOfPixels() >= 0 )
     img.addPixels( PixelsI() )
     self.assert_( 1==img.sizeOfPixels() )
     img.unloadPixels()
     self.assert_( img.sizeOfPixels() < 0 )
예제 #19
0
 def testUnloadSet(self):
     img = ImageI()
     assert img.sizeOfPixels() >= 0
     img.addPixels(PixelsI())
     assert 1 == img.sizeOfPixels()
     img.unloadPixels()
     assert img.sizeOfPixels() < 0
예제 #20
0
    def test1184(self):
        uuid = self.uuid()
        client = self.new_client(perms="rw----")

        share = client.sf.getShareService()
        query = client.sf.getQueryService()
        update = client.sf.getUpdateService()
        admin = client.sf.getAdminService()
        cont = client.sf.getContainerService()

        ds = DatasetI()
        ds.setName(rstring('test1184-ds-%s' % (uuid)))

        for i in range(1,2001):
            img = ImageI()
            img.setName(rstring('img1184-%s' % (uuid)))
            img.setAcquisitionDate(rtime(time.time()))
            # Saving in one go
            #dil = DatasetImageLinkI()
            #dil.setParent(ds)
            #dil.setChild(img)
            #update.saveObject(dil)
            ds.linkImage(img)
        ds = update.saveAndReturnObject(ds)

        c = cont.getCollectionCount(ds.__class__.__name__, ("imageLinks"), [ds.id.val], None)
        assert c[ds.id.val] == 2000

        page = 1
        p = omero.sys.Parameters()
        p.map = {}
        p.map["eid"] = rlong(admin.getEventContext().userId)
        p.map["oid"] = rlong(ds.id.val)
        if page is not None:
            f = omero.sys.Filter()
            f.limit = rint(24)
            f.offset = rint((int(page)-1)*24)
            p.theFilter = f

        sql = "select im from Image im join fetch im.details.owner join fetch im.details.group " \
              "left outer join fetch im.datasetLinks dil left outer join fetch dil.parent d " \
              "where d.id = :oid and im.details.owner.id=:eid order by im.id asc"

        start = time.time()
        res = query.findAllByQuery(sql,p)
        assert 24 ==  len(res)
        end = time.time()
        elapsed = end - start
        assert elapsed < 3.0,\
            "Expected the test to complete in < 3 seconds, took: %f" % elapsed
예제 #21
0
 def testUnloadCheckPtr(self):
     img = ImageI()
     self.assert_(img.isLoaded())
     self.assert_(img.getDetails())  # details are auto instantiated
     self.assert_(not img.getName())  # no other single-valued field is
     img.unload()
     self.assert_(not img.isLoaded())
     self.assertRaises(omero.UnloadedEntityException, img.getDetails)
예제 #22
0
 def testSequences(self):
     img = ImageI()
     assert img.sizeOfAnnotationLinks() >= 0
     img.linkAnnotation(None)
     img.unload()
     try:
         assert not img.sizeOfAnnotationLinks() >= 0
         assert len(img.copyAnnotationLinks()) == 0
         assert False, "can't reach here"
     except:
         # These are true, but can't be tested
         pass
예제 #23
0
 def testSequences(self):
     img = ImageI()
     self.assert_(img.sizeOfAnnotationLinks() >= 0)
     img.linkAnnotation(None)
     img.unload()
     try:
         self.assert_(not img.sizeOfAnnotationLinks() >= 0)
         self.assert_(len(img.copyAnnotationLinks()) == 0)
         self.fail("can't reach here")
     except:
         # These are true, but can't be tested
         pass
예제 #24
0
    def testGetAttrBad(self):
        i = ImageI()

        def assign_loaded():
            i.loaded = False
        pytest.raises(AttributeError, assign_loaded)
        pytest.raises(AttributeError, lambda: i.foo)

        def assign_foo():
            i.foo = 1
        pytest.raises(AttributeError, assign_foo)
        pytest.raises(AttributeError, lambda: i.annotationLinks)
        pytest.raises(AttributeError, lambda: i.getAnnotationLinks())

        def assign_links():
            i.annotationLinks = []
        pytest.raises(AttributeError, assign_links)
예제 #25
0
    def testRemoveFromSet(self):
        pix = PixelsI()
        img = ImageI()
        self.assert_( img.sizeOfPixels() >= 0 )

        img.addPixels( pix )
        self.assert_( 1==img.sizeOfPixels() )

        img.removePixels( pix )
        self.assert_( 0==img.sizeOfPixels() )
예제 #26
0
    def testRemoveFromSet(self):
        pix = PixelsI()
        img = ImageI()
        assert img.sizeOfPixels() >= 0

        img.addPixels(pix)
        assert 1 == img.sizeOfPixels()

        img.removePixels(pix)
        assert 0 == img.sizeOfPixels()
예제 #27
0
 def testUnloadCheckPtr(self):
     img = ImageI()
     assert img.isLoaded()
     assert img.getDetails()  # details are auto instantiated
     assert not img.getName()  # no other single-valued field is
     img.unload()
     assert not img.isLoaded()
     pytest.raises(omero.UnloadedEntityException, img.getDetails)
예제 #28
0
 def testCreateAfterBlitzPort(self):
     ipojo = self.client.sf.getContainerService()
     i = ImageI()
     i.setName(rstring("name"))
     i.setAcquisitionDate(rtime(0))
     i = ipojo.createDataObject(i, None)
     o = i.getDetails().owner
     self.assertEquals(-1, o.sizeOfGroupExperimenterMap())
예제 #29
0
 def testSequences(self):
     img = ImageI()
     assert img.sizeOfAnnotationLinks() >= 0
     img.linkAnnotation(None)
     img.unload()
     try:
         assert not img.sizeOfAnnotationLinks() >= 0
         assert len(img.copyAnnotationLinks()) == 0
         assert False, "can't reach here"
     except:
         # These are true, but can't be tested
         pass
예제 #30
0
 def testSequences(self):
     img = ImageI()
     self.assert_( img.sizeOfAnnotationLinks() >= 0 )
     img.linkAnnotation(None)
     img.unload()
     try:
         self.assert_( not img.sizeOfAnnotationLinks() >= 0 )
         self.assert_( len(img.copyAnnotationLinks()) == 0 )
         self.fail("can't reach here")
     except:
         # These are true, but can't be tested
         pass
예제 #31
0
    def test2327(self):

        ### create two users in two groups
        client_share1, user1 = self.new_client_and_user()
        client_share2, user2 = self.new_client_and_user()

        ## login as user1
        share1 = client_share1.sf.getShareService()
        update1 = client_share1.sf.getUpdateService()

        # create image
        img = ImageI()
        img.setName(rstring('test2327'))
        img.setAcquisitionDate(rtime(0))
        img = update1.saveAndReturnObject(img)
        img.unload()

        # create share
        description = "my description"
        timeout = None
        objects = [img]
        experimenters = [user2]
        guests = []
        enabled = True
        sid = share1.createShare(description, timeout, objects, experimenters,
                                 guests, enabled)
        self.assert_(len(share1.getContents(sid)) == 1)
        # add comment by the owner
        share1.addComment(sid, 'test comment by the owner %s' % user1.id.val)

        ## login as user2
        share2 = client_share2.sf.getShareService()
        query2 = client_share2.sf.getQueryService()

        l = share2.getMemberShares(False)
        self.assertEquals(1, len(l))

        # add comment by the member
        share2.addComment(sid,
                          'test comment by the member %s' % (user2.id.val))

        # Don't have to activate share2

        #get comments
        # by user1
        c1 = len(share1.getComments(sid))
        self.assertEquals(2, c1)
        # by user2
        c2 = len(share2.getComments(sid))
        self.assertEquals(2, c2)
예제 #32
0
 def testCreateAfterBlitzPort(self):
     ipojo = self.client.sf.getContainerService()
     i = ImageI()
     i.setName(rstring("name"))
     i.setAcquisitionDate(rtime(0))
     i = ipojo.createDataObject(i,None)
     o = i.getDetails().owner
     self.assertEquals( -1, o.sizeOfGroupExperimenterMap() )
예제 #33
0
    def test1154(self):
        uuid = self.root.sf.getAdminService().getEventContext().sessionUuid

        ### create two users in one group
        client_share1, user1 = self.new_client_and_user()
        client_share2, user2 = self.new_client_and_user()

        ## login as user1
        share1 = client_share1.sf.getShareService()
        update1 = client_share1.sf.getUpdateService()

        # create image
        img = ImageI()
        img.setName(rstring('test1154-img-%s' % (uuid)))
        img.setAcquisitionDate(rtime(0))
        img = update1.saveAndReturnObject(img)
        img.unload()

        # create share
        description = "my description"
        timeout = None
        objects = [img]
        experimenters = [user2]
        guests = []
        enabled = True
        sid = share1.createShare(description, timeout, objects, experimenters,
                                 guests, enabled)

        self.assertEquals(1, len(share1.getContents(sid)))

        ## login as user2
        share2 = client_share2.sf.getShareService()
        query2 = client_share2.sf.getQueryService()

        content = share2.getContents(sid)
        self.assertEquals(1, len(share2.getContents(sid)))

        # get shared image when share is activated
        share2.activate(sid)

        p = omero.sys.Parameters()
        p.map = {}
        p.map["ids"] = rlist([rlong(img.id.val)])
        sql = "select im from Image im where im.id in (:ids) order by im.name"
        res = query2.findAllByQuery(sql, p)
        self.assertEquals(1, len(res))
        for e in res:
            self.assert_(e.id.val == img.id.val)
예제 #34
0
    def test1157(self):
        uuid = self.root.sf.getAdminService().getEventContext().sessionUuid
        share = self.root.sf.getShareService()

        ### create two users in one group
        client_share1, user1 = self.new_client_and_user()
        client_share2, user2 = self.new_client_and_user()

        ## login as user1
        share1 = client_share1.sf.getShareService()
        update1 = client_share1.sf.getUpdateService()

        # create image
        img = ImageI()
        img.setName(rstring('test1154-img-%s' % (uuid)))
        img.setAcquisitionDate(rtime(0))
        img = update1.saveAndReturnObject(img)
        img.unload()

        # create share
        description = "my description"
        timeout = None
        objects = [img]
        experimenters = [user2]
        guests = []
        enabled = True
        sid = share1.createShare(description, timeout, objects, experimenters,
                                 guests, enabled)
        self.assert_(len(share1.getContents(sid)) == 1)
        # add comment by the owner
        share.addComment(sid, 'test comment by the owner %s' % (uuid))

        ## login as user2
        share2 = client_share2.sf.getShareService()
        query2 = client_share2.sf.getQueryService()

        # add comment by the member
        share2.addComment(sid, 'test comment by the member %s' % (uuid))

        # Don't have to activate share2

        #get comments
        # by user1
        c1 = len(share.getComments(sid))
        self.assertEquals(2, c1)
        # by user2
        c2 = len(share2.getComments(sid))
        self.assertEquals(2, c2)
예제 #35
0
    def testLinkingAndUnlinking(self):
        d = DatasetI()
        i = ImageI()

        d.linkImage(i)
        self.assert_(d.sizeOfImageLinks() == 1)
        d.unlinkImage(i)
        self.assert_(d.sizeOfImageLinks() == 0)

        d = DatasetI()
        i = ImageI()
        d.linkImage(i)
        self.assert_(i.sizeOfDatasetLinks() == 1)
        i.unlinkDataset(d)
        self.assert_(d.sizeOfImageLinks() == 0)

        d = DatasetI()
        i = ImageI()
        dil = DatasetImageLinkI()
        dil.link(d, i)
        d.addDatasetImageLink(dil, False)
        self.assert_(d.sizeOfImageLinks() == 1)
        self.assert_(i.sizeOfDatasetLinks() == 0)
예제 #36
0
    def testLinkingAndUnlinking(self):
        d = DatasetI()
        i = ImageI()

        d.linkImage(i)
        assert d.sizeOfImageLinks() == 1
        d.unlinkImage(i)
        assert d.sizeOfImageLinks() == 0

        d = DatasetI()
        i = ImageI()
        d.linkImage(i)
        assert i.sizeOfDatasetLinks() == 1
        i.unlinkDataset(d)
        assert d.sizeOfImageLinks() == 0

        d = DatasetI()
        i = ImageI()
        dil = DatasetImageLinkI()
        dil.link(d, i)
        d.addDatasetImageLink(dil, False)
        assert d.sizeOfImageLinks() == 1
        assert i.sizeOfDatasetLinks() == 0
예제 #37
0
    def test2327(self):

        ### create two users in two groups
        client_share1, user1 = self.new_client_and_user()
        client_share2, user2 = self.new_client_and_user()

        ## login as user1
        share1 = client_share1.sf.getShareService()
        update1 = client_share1.sf.getUpdateService()

        # create image
        img = ImageI()
        img.setName(rstring('test2327'))
        img.setAcquisitionDate(rtime(0))
        img = update1.saveAndReturnObject(img)
        img.unload()

        # create share
        description = "my description"
        timeout = None
        objects = [img]
        experimenters = [user2]
        guests = []
        enabled = True
        sid = share1.createShare(description, timeout, objects, experimenters, guests, enabled)
        self.assert_(len(share1.getContents(sid)) == 1)
        # add comment by the owner
        share1.addComment(sid, 'test comment by the owner %s' % user1.id.val)

        ## login as user2
        share2 = client_share2.sf.getShareService()
        query2 = client_share2.sf.getQueryService()

        l = share2.getMemberShares(False)
        self.assertEquals(1, len(l))

        # add comment by the member
        share2.addComment(sid, 'test comment by the member %s' % (user2.id.val))

        # Don't have to activate share2

        #get comments
        # by user1
        c1 = len(share1.getComments(sid))
        self.assertEquals(2, c1)
        # by user2
        c2 = len(share2.getComments(sid))
        self.assertEquals(2, c2)
예제 #38
0
    def test1154(self):
        uuid = self.root.sf.getAdminService().getEventContext().sessionUuid

        
        ### create two users in one group
        client_share1, user1 = self.new_client_and_user()
        client_share2, user2 = self.new_client_and_user()

        ## login as user1
        share1 = client_share1.sf.getShareService()
        update1 = client_share1.sf.getUpdateService()
        
        # create image
        img = ImageI()
        img.setName(rstring('test1154-img-%s' % (uuid)))
        img.setAcquisitionDate(rtime(0))
        img = update1.saveAndReturnObject(img)
        img.unload()
        
        # create share
        description = "my description"
        timeout = None
        objects = [img]
        experimenters = [user2]
        guests = []
        enabled = True
        sid = share1.createShare(description, timeout, objects,experimenters, guests, enabled)
        
        self.assertEquals(1,len(share1.getContents(sid)))
        
        ## login as user2
        share2 = client_share2.sf.getShareService()
        query2 = client_share2.sf.getQueryService()
        
        content = share2.getContents(sid)
        self.assertEquals(1,len(share2.getContents(sid)))
        
        # get shared image when share is activated
        share2.activate(sid)

        p = omero.sys.Parameters()
        p.map = {}
        p.map["ids"] = rlist([rlong(img.id.val)])
        sql = "select im from Image im where im.id in (:ids) order by im.name"
        res = query2.findAllByQuery(sql, p)
        self.assertEquals(1,len(res))
        for e in res:
            self.assert_(e.id.val == img.id.val)
예제 #39
0
    def test1157(self):
        uuid = self.root.sf.getAdminService().getEventContext().sessionUuid
        share = self.root.sf.getShareService()
        
        ### create two users in one group
        client_share1, user1 = self.new_client_and_user()
        client_share2, user2 = self.new_client_and_user()
        
        ## login as user1 
        share1 = client_share1.sf.getShareService()
        update1 = client_share1.sf.getUpdateService()
        
        # create image
        img = ImageI()
        img.setName(rstring('test1154-img-%s' % (uuid)))
        img.setAcquisitionDate(rtime(0))
        img = update1.saveAndReturnObject(img)
        img.unload()
        
        # create share
        description = "my description"
        timeout = None
        objects = [img]
        experimenters = [user2]
        guests = []
        enabled = True
        sid = share1.createShare(description, timeout, objects,experimenters, guests, enabled)
        self.assert_(len(share1.getContents(sid)) == 1)
        # add comment by the owner
        share.addComment(sid, 'test comment by the owner %s' % (uuid))
        
        ## login as user2
        share2 = client_share2.sf.getShareService()
        query2 = client_share2.sf.getQueryService()
        
        # add comment by the member
        share2.addComment(sid, 'test comment by the member %s' % (uuid))

        # Don't have to activate share2

        #get comments
        # by user1
        c1 = len(share.getComments(sid))
        self.assertEquals(2,c1)
        # by user2
        c2 = len(share2.getComments(sid))
        self.assertEquals(2,c2)
예제 #40
0
    def test1184(self):
        uuid = self.uuid()
        client = self.new_client(perms="rw----")

        share = client.sf.getShareService()
        query = client.sf.getQueryService()
        update = client.sf.getUpdateService()
        admin = client.sf.getAdminService()
        cont = client.sf.getContainerService()

        ds = DatasetI()
        ds.setName(rstring('test1184-ds-%s' % (uuid)))

        for i in range(1, 2001):
            img = ImageI()
            img.setName(rstring('img1184-%s' % (uuid)))
            img.setAcquisitionDate(rtime(time.time()))
            # Saving in one go
            #dil = DatasetImageLinkI()
            #dil.setParent(ds)
            #dil.setChild(img)
            #update.saveObject(dil)
            ds.linkImage(img)
        ds = update.saveAndReturnObject(ds)

        c = cont.getCollectionCount(ds.__class__.__name__, ("imageLinks"),
                                    [ds.id.val], None)
        self.assert_(c[ds.id.val] == 2000)

        page = 1
        p = omero.sys.Parameters()
        p.map = {}
        p.map["eid"] = rlong(admin.getEventContext().userId)
        p.map["oid"] = rlong(ds.id.val)
        if page is not None:
            f = omero.sys.Filter()
            f.limit = rint(24)
            f.offset = rint((int(page) - 1) * 24)
            p.theFilter = f

        sql = "select im from Image im join fetch im.details.owner join fetch im.details.group " \
              "left outer join fetch im.datasetLinks dil left outer join fetch dil.parent d " \
              "where d.id = :oid and im.details.owner.id=:eid order by im.id asc"

        start = time.time()
        res = query.findAllByQuery(sql, p)
        self.assertEquals(24, len(res))
        end = time.time()
        elapsed = end - start
        self.assertTrue(
            elapsed < 3.0,
            "Expected the test to complete in < 3 seconds, took: %f" % elapsed)
예제 #41
0
    def test1163(self):
        uuid = self.uuid()
        new_gr1 = self.new_group(perms="rw----")
        client_share1, new_exp_obj = self.new_client_and_user(new_gr1)
        update1 = client_share1.sf.getUpdateService()
        search1 = client_share1.sf.createSearchService()

        # create image and index
        img = ImageI()
        img.setName(rstring('test1154-img-%s' % (uuid)))
        img.setAcquisitionDate(rtime(0))
        img = update1.saveAndReturnObject(img)
        img.unload()
        self.index(img)

        # search
        search1.onlyType('Image')
        search1.addOrderByAsc("name")
        search1.byFullText("test*")
        self.assertTrue(search1.hasNext())
        res = search1.results()
        self.assertEquals(1, len(res))
예제 #42
0
    def test2327(self):
        # create two users in two groups
        client_share1, user1 = self.new_client_and_user()
        client_share2, user2 = self.new_client_and_user()

        # login as user1
        share1 = client_share1.sf.getShareService()
        update1 = client_share1.sf.getUpdateService()

        # create image
        img = ImageI()
        img.setName(rstring("test2327"))
        img.setAcquisitionDate(rtime(0))
        img = update1.saveAndReturnObject(img)
        img.unload()

        # create share
        description = "my description"
        timeout = None
        objects = [img]
        experimenters = [user2]
        guests = []
        enabled = True
        sid = share1.createShare(description, timeout, objects, experimenters, guests, enabled)
        assert len(share1.getContents(sid)) == 1
        # add comment by the owner
        share1.addComment(sid, "test comment by the owner %s" % user1.id.val)

        # login as user2
        share2 = client_share2.sf.getShareService()
        l = share2.getMemberShares(False)
        assert 1 == len(l)

        # add comment by the member
        share2.addComment(sid, "test comment by the member %s" % user2.id.val)

        # get comments
        # by user1
        c1 = len(share1.getComments(sid))
        assert 2 == c1
        # by user2
        c2 = len(share2.getComments(sid))
        assert 2 == c2
예제 #43
0
    def testBasicUsage(self):
        usr = self.client.sf.getAdminService().getEventContext().userId

        img = ImageI()
        img.name = rstring("name")
        img.acquisitionDate = rtime(0)
        tag = TagAnnotationI()
        img.linkAnnotation(tag)

        img = self.client.sf.getUpdateService().saveAndReturnObject(img)

        img = self.client.sf.getQueryService().findByQuery(
            """
        select img from Image img
        join fetch img.annotationLinksCountPerOwner
        where img.id = %s
        """ % (img.id.val), None)
        self.assert_(img)
        self.assert_(img.getAnnotationLinksCountPerOwner()[usr] > 0)
예제 #44
0
    def test8118(self):
        uuid = self.root.sf.getAdminService().getEventContext().sessionUuid
        share_serv = self.root.sf.getShareService()
        update_serv = self.root.sf.getUpdateService()

        # create user
        user1 = self.new_user()

        # create image
        img = ImageI()
        img.setName(rstring('test8118-img-%s' % (uuid)))
        img.setAcquisitionDate(rtime(0))
        img = update_serv.saveAndReturnObject(img)
        img.unload()

        # create share
        description = "my description"
        timeout = None
        objects = [img]
        experimenters = [user1]
        guests = []
        enabled = True
        sid = share_serv.createShare(description, timeout, objects,
                                     experimenters, guests, enabled)
        suuid = share_serv.getShare(sid).uuid

        self.assertEquals(1, len(share_serv.getContents(sid)))

        # join share
        user1_client = omero.client()
        try:
            user1_client.createSession(suuid, suuid)
            user1_share = user1_client.sf.getShareService()
            user1_share.activate(sid)
            self.assertEquals(1, len(user1_share.getContents(sid)))
        finally:
            user1_client.__del__()
예제 #45
0
    def test_none_pixel_size(self):
        """
        Tests display of core metatada still works even when image
        doesn't have pixels data
        """
        img = ImageI()
        img.setName(rstring("no_pixels"))
        img.setDescription(rstring("empty image without pixels data"))

        conn = omero.gateway.BlitzGateway(client_obj=self.client)
        img = conn.getUpdateService().saveAndReturnObject(img)

        request_url = reverse('load_metadata_details',
                              args=['image', img.id.val])

        # Just check that the metadata panel is loaded
        rsp = get(self.django_client, request_url, status_code=200)
        assert "no_pixels" in rsp.content.decode("utf-8")
예제 #46
0
    def test1163(self):
        uuid = self.uuid()
        new_gr1 = self.new_group(perms="rw----")
        client_share1, new_exp_obj = self.new_client_and_user(new_gr1)
        update1 = client_share1.sf.getUpdateService()
        search1 = client_share1.sf.createSearchService()

        # create image and index
        img = ImageI()
        img.setName(rstring('test1154-img-%s' % (uuid)))
        img.setAcquisitionDate(rtime(0))
        img = update1.saveAndReturnObject(img)
        img.unload()
        self.index(img)

        # search
        search1.onlyType('Image')
        search1.addOrderByAsc("name")
        search1.byFullText("test*")
        assert search1.hasNext()
        res = search1.results()
        assert 1 ==  len(res)
예제 #47
0
    def testLinkingAndUnlinking(self):
        d = DatasetI()
        i = ImageI()

        d.linkImage(i)
        self.assert_( d.sizeOfImageLinks() == 1 )
        d.unlinkImage(i)
        self.assert_( d.sizeOfImageLinks() == 0 )

        d = DatasetI()
        i = ImageI()
        d.linkImage(i)
        self.assert_( i.sizeOfDatasetLinks() == 1 )
        i.unlinkDataset(d)
        self.assert_( d.sizeOfImageLinks() == 0 )

        d = DatasetI()
        i = ImageI()
        dil = DatasetImageLinkI()
        dil.link(d,i)
        d.addDatasetImageLink(dil, False)
        self.assert_( d.sizeOfImageLinks() == 1 )
        self.assert_( i.sizeOfDatasetLinks() == 0 )
예제 #48
0
    def testLinkingAndUnlinking(self):
        d = DatasetI()
        i = ImageI()

        d.linkImage(i)
        assert d.sizeOfImageLinks() == 1
        d.unlinkImage(i)
        assert d.sizeOfImageLinks() == 0

        d = DatasetI()
        i = ImageI()
        d.linkImage(i)
        assert i.sizeOfDatasetLinks() == 1
        i.unlinkDataset(d)
        assert d.sizeOfImageLinks() == 0

        d = DatasetI()
        i = ImageI()
        dil = DatasetImageLinkI()
        dil.link(d, i)
        d.addDatasetImageLink(dil, False)
        assert d.sizeOfImageLinks() == 1
        assert i.sizeOfDatasetLinks() == 0
예제 #49
0
    def testBasicUsage(self):
        usr = self.client.sf.getAdminService().getEventContext().userId

        img = ImageI()
        img.name = rstring("name")
        img.acquisitionDate = rtime(0)
        tag = TagAnnotationI()
        img.linkAnnotation(tag)

        img = self.client.sf.getUpdateService().saveAndReturnObject(img)

        img = self.client.sf.getQueryService().findByQuery(
            """
            select img from Image img
            join fetch img.annotationLinksCountPerOwner
            where img.id = %s
            """ % (img.id.val), None
            )
        assert img
        assert img.getAnnotationLinksCountPerOwner()[usr] > 0
예제 #50
0
 def test8118(self):
     uuid = self.root.sf.getAdminService().getEventContext().sessionUuid
     share_serv = self.root.sf.getShareService()
     update_serv = self.root.sf.getUpdateService()
     
     # create user
     user1 = self.new_user()
     
     # create image
     img = ImageI()
     img.setName(rstring('test8118-img-%s' % (uuid)))
     img.setAcquisitionDate(rtime(0))
     img = update_serv.saveAndReturnObject(img)
     img.unload()
     
     # create share
     description = "my description"
     timeout = None
     objects = [img]
     experimenters = [user1]
     guests = []
     enabled = True
     sid = share_serv.createShare(description, timeout, objects,experimenters, guests, enabled)
     suuid = share_serv.getShare(sid).uuid
     
     self.assertEquals(1,len(share_serv.getContents(sid)))
     
     # join share
     user1_client = omero.client()
     try:
         user1_client.createSession(suuid,suuid)
         user1_share = user1_client.sf.getShareService()
         user1_share.activate(sid)
         self.assertEquals(1, len(user1_share.getContents(sid)))
     finally:
         user1_client.__del__()
예제 #51
0
    def test1071(self):
        uuid = self.root.sf.getAdminService().getEventContext().sessionUuid
        pojos = self.root.sf.getContainerService()
        query = self.root.sf.getQueryService()
        update = self.root.sf.getUpdateService()

        #projects
        pr1 = ProjectI()
        pr1.setName(rstring('test1071-pr1-%s' % (uuid)))
        pr1 = update.saveAndReturnObject(pr1)
        pr1.unload()

        pr2 = ProjectI()
        pr2.setName(rstring('test1071-pr2-%s' % (uuid)))
        pr2 = update.saveAndReturnObject(pr2)
        pr2.unload()

        #datasets
        ds1 = DatasetI()
        ds1.setName(rstring('test1071-ds1-%s' % (uuid)))
        ds1 = update.saveAndReturnObject(ds1)
        ds1.unload()

        ds2 = DatasetI()
        ds2.setName(rstring('test1071-ds2-%s' % (uuid)))
        ds2 = update.saveAndReturnObject(ds2)
        ds2.unload()

        ds3 = DatasetI()
        ds3.setName(rstring('test1071-ds3-%s' % (uuid)))
        ds3 = update.saveAndReturnObject(ds3)
        ds3.unload()

        #images
        im2 = ImageI()
        im2.setName(rstring('test1071-im2-%s' % (uuid)))
        im2.acquisitionDate = rtime(0)
        im2 = update.saveAndReturnObject(im2)
        im2.unload()

        #links
        #
        # im2 -> ds3
        #    +-> ds2 --> pr2
        #    |       \
        #    \-> ds1 --> pr1
        #
        pdl1 = ProjectDatasetLinkI()
        pdl1.setParent(pr1)
        pdl1.setChild(ds1)
        update.saveObject(pdl1)

        pdl2 = ProjectDatasetLinkI()
        pdl2.setParent(pr1)
        pdl2.setChild(ds2)
        update.saveObject(pdl2)

        pdl3 = ProjectDatasetLinkI()
        pdl3.setParent(pr2)
        pdl3.setChild(ds2)
        update.saveObject(pdl3)

        dil4 = DatasetImageLinkI()
        dil4.setParent(ds1)
        dil4.setChild(im2)
        update.saveObject(dil4)

        dil5 = DatasetImageLinkI()
        dil5.setParent(ds2)
        dil5.setChild(im2)
        update.saveObject(dil5)

        dil6 = DatasetImageLinkI()
        dil6.setParent(ds3)
        dil6.setChild(im2)
        update.saveObject(dil6)

        #test:
        hier = pojos.findContainerHierarchies("Project", [long(im2.id.val)], None)

        assert 3 ==  len(hier), "len of hier != 3: %s" % [type(x) for x in hier]
        for c in hier:
            if c.id.val == pr1.id.val and isinstance(c, ProjectI):
                assert c.sizeOfDatasetLinks() == 2, "length 2 != " + str(c.sizeOfDatasetLinks())
                for pdl in c.copyDatasetLinks():
                    assert pdl.child.sizeOfImageLinks() == 1
                    for dil in pdl.child.copyImageLinks():
                        assert dil.child.id.val == im2.id.val
            elif c.id.val == pr2.id.val and isinstance(c, ProjectI):
                assert  c.sizeOfDatasetLinks() == 1
            elif c.id.val == ds3.id.val and isinstance(c, DatasetI):
                assert  c.sizeOfImageLinks() == 1
예제 #52
0
    def test1071_1(self):
        admin = self.root.sf.getAdminService()

        common_group = self.new_group(perms="rwrw--")
        c1 = self.new_client(common_group)
        c2 = self.new_client(common_group)

        c1_pojos = c1.sf.getContainerService()
        c1_query = c1.sf.getQueryService()
        c1_update = c1.sf.getUpdateService()
        c1_uuid = c1.sf.getAdminService().getEventContext().sessionUuid

        c2_pojos = c2.sf.getContainerService()
        c2_query = c2.sf.getQueryService()
        c2_update = c2.sf.getUpdateService()
        c2_uuid = c2.sf.getAdminService().getEventContext().sessionUuid

        #projects
        pr1 = ProjectI()
        pr1.setName(rstring('test1071-pr1-%s' % (c1_uuid)))
        pr1 = c1_update.saveAndReturnObject(pr1)
        pr1.unload()

        pr2 = ProjectI()
        pr2.setName(rstring('test1071-pr2-%s' % (c2_uuid)))
        pr2 = c2_update.saveAndReturnObject(pr2)
        pr2.unload()

        #datasets
        ds1 = DatasetI()
        ds1.setName(rstring('test1071-ds1-%s' % (c1_uuid)))
        ds1 = c1_update.saveAndReturnObject(ds1)
        ds1.unload()

        ds2 = DatasetI()
        ds2.setName(rstring('test1071-ds2-%s' % (c2_uuid)))
        ds2 = c2_update.saveAndReturnObject(ds2)
        ds2.unload()

        #images
        im2 = ImageI()
        im2.setName(rstring('test1071-im2-%s' % (c2_uuid)))
        im2.acquisitionDate = rtime(0)
        im2 = c2_update.saveAndReturnObject(im2)
        im2.unload()

        #links
        # im2 owned by u2
        #
        # im2   -> ds2 --> pr2 (owned by u2)
        #      |
        #      \-> ds1 --> pr1 (owned by u1)
        #
        pdl1 = ProjectDatasetLinkI()
        pdl1.setParent(pr1)
        pdl1.setChild(ds1)
        c1_update.saveObject(pdl1)

        pdl2 = ProjectDatasetLinkI()
        pdl2.setParent(pr2)
        pdl2.setChild(ds2)
        c2_update.saveObject(pdl2)

        dil2 = DatasetImageLinkI()
        dil2.setParent(ds2)
        dil2.setChild(im2)
        c2_update.saveObject(dil2)

        dil1 = DatasetImageLinkI()
        dil1.setParent(ds1)
        dil1.setChild(im2)
        c1_update.saveObject(dil1)

        #test:
        hier = c2_pojos.findContainerHierarchies("Project", [long(im2.id.val)], None)

        assert 2 ==  len(hier), "size of hier != 2: %s" % [type(x) for x in hier]
        for c in hier:
            if c.id.val == pr1.id.val and isinstance(c, ProjectI):
                assert 1 ==  c.sizeOfDatasetLinks()
                for pdl in c.copyDatasetLinks():
                    assert 1 ==  pdl.child.sizeOfImageLinks()
                    for dil in pdl.child.copyImageLinks():
                        assert dil.child.id.val == im2.id.val
            elif c.id.val == pr2.id.val and isinstance(c, ProjectI):
                assert 1 ==  c.sizeOfDatasetLinks()
            elif c.id.val == ds3.id.val and isinstance(c, DatasetI):
                assert 1 ==  c.sizeOfImageLinks()
예제 #53
0
 def testUnloadField(self):
     img = ImageI()
     self.assert_(img.getDetails())
     img.unloadDetails()
     self.assert_(not img.getDetails())
예제 #54
0
    def testAccessors(self):
        name = rstring("name")
        img = ImageI()
        self.assert_(not img.getName())
        img.setName(name)
        self.assert_(img.getName())
        name = img.getName()
        self.assert_(name.val == "name")
        self.assert_(name == name)

        img.setName(rstring("name2"))
        self.assert_(img.getName().val == "name2")
        self.assert_(img.getName())

        img.unload()
        try:
            self.assert_(not img.getName())
            self.fail("should fail")
        except:
            # Is true, but cannot test
            pass
예제 #55
0
 def testSimpleCtor(self):
     img = ImageI()
     assert img.isLoaded()
     assert img.sizeOfPixels() >= 0
예제 #56
0
 def testVirtual(self):
     img = ImageI()
     imgI = ImageI()
     img.unload()
     imgI.unload()
예제 #57
0
    def test1172(self):
        uuid = self.root.sf.getAdminService().getEventContext().sessionUuid
        share = self.root.sf.getShareService()
        query = self.root.sf.getQueryService()
        update = self.root.sf.getUpdateService()

        ### create user
        client_share1, user1 = self.new_client_and_user()

        #create dataset with image
        #dataset with image
        ds = omero.model.DatasetI()
        ds.setName(rstring("dataset-%s" % (uuid)))
        ds = update.saveAndReturnObject(ds)
        ds.unload()

        # create image
        img = ImageI()
        img.setName(rstring('test-img in dataset-%s' % (uuid)))
        img.setAcquisitionDate(rtime(0))
        img = update.saveAndReturnObject(img)
        img.unload()

        dil = DatasetImageLinkI()
        dil.setParent(ds)
        dil.setChild(img)
        dil = update.saveAndReturnObject(dil)
        dil.unload()

        # create share by root
        items = list()
        ms = list()

        p = omero.sys.Parameters()
        p.map = {}
        p.map["oid"] = ds.id
        sql = "select ds from Dataset ds join fetch ds.details.owner join fetch ds.details.group " \
              "left outer join fetch ds.imageLinks dil left outer join fetch dil.child i " \
              "where ds.id=:oid"
        items.extend(query.findAllByQuery(sql, p))
        self.assertEquals(1, len(items))

        #members
        p.map["eid"] = rlong(user1.id.val)
        sql = "select e from Experimenter e where e.id =:eid order by e.omeName"
        ms = query.findAllByQuery(sql, p)
        sid = share.createShare(("test-share-%s" % uuid),
                                rtime(long(time.time() * 1000 + 86400)), items,
                                ms, [], True)

        # USER RETRIEVAL
        ## login as user1
        share1 = client_share1.sf.getShareService()
        query1 = client_share1.sf.getQueryService()
        cntar1 = client_share1.sf.getContainerService()

        content = share1.getContents(sid)
        # Content now contains just the dataset with nothing loaded
        self.assertEquals(1, len(content))

        # get shared dataset and image when share is activated
        share1.activate(sid)

        #retrieve dataset
        p = omero.sys.Parameters()
        p.map = {}
        p.map["ids"] = rlist([ds.id])
        sql = "select ds from Dataset ds join fetch ds.details.owner join fetch ds.details.group " \
              "left outer join fetch ds.imageLinks dil left outer join fetch dil.child i " \
              "where ds.id in (:ids) order by ds.name"
        try:
            res1 = query1.findAllByQuery(sql, p)
            self.fail("This should throw an exception")
        except:
            pass

        #
        # Now we add all the other elements to the share to prevent
        # the security violation
        #
        # Not working imgs = cntar.getImages("Dataset",[ds.id.val], None)
        img = query.findByQuery(
            "select i from Image i join fetch i.datasetLinks dil join dil.parent d where d.id = %s "
            % ds.id.val, None)
        self.assert_(img)
        share.addObject(sid, img)
        share.addObjects(sid, img.copyDatasetLinks())
        self.assertEquals(3, len(share.getContents(sid)))

        #
        # And try again to load them
        #
        share1.activate(sid)
        res1 = query1.findAllByQuery(sql, p)
        self.assert_(len(res1) == 1)
        for e in res1:
            self.assert_(e.id.val == ds.id.val)

        # retrieve only image
        p = omero.sys.Parameters()
        p.map = {}
        p.map["oid"] = rlong(img.id)
        sql = "select im from Image im " \
              "where im.id=:oid order by im.name"
        res2 = query1.findByQuery(sql, p)
        self.assert_(res2.id.val == img.id.val)
예제 #58
0
    def test1071(self):
        uuid = self.root.sf.getAdminService().getEventContext().sessionUuid
        pojos = self.root.sf.getContainerService()
        query = self.root.sf.getQueryService()
        update = self.root.sf.getUpdateService()

        #projects
        pr1 = ProjectI()
        pr1.setName(rstring('test1071-pr1-%s' % (uuid)))
        pr1 = update.saveAndReturnObject(pr1)
        pr1.unload()

        pr2 = ProjectI()
        pr2.setName(rstring('test1071-pr2-%s' % (uuid)))
        pr2 = update.saveAndReturnObject(pr2)
        pr2.unload()

        #datasets
        ds1 = DatasetI()
        ds1.setName(rstring('test1071-ds1-%s' % (uuid)))
        ds1 = update.saveAndReturnObject(ds1)
        ds1.unload()

        ds2 = DatasetI()
        ds2.setName(rstring('test1071-ds2-%s' % (uuid)))
        ds2 = update.saveAndReturnObject(ds2)
        ds2.unload()

        ds3 = DatasetI()
        ds3.setName(rstring('test1071-ds3-%s' % (uuid)))
        ds3 = update.saveAndReturnObject(ds3)
        ds3.unload()

        #images
        im2 = ImageI()
        im2.setName(rstring('test1071-im2-%s' % (uuid)))
        im2.acquisitionDate = rtime(0)
        im2 = update.saveAndReturnObject(im2)
        im2.unload()

        #links
        #
        # im2 -> ds3
        #    +-> ds2 --> pr2
        #    |       \
        #    \-> ds1 --> pr1
        #
        pdl1 = ProjectDatasetLinkI()
        pdl1.setParent(pr1)
        pdl1.setChild(ds1)
        update.saveObject(pdl1)

        pdl2 = ProjectDatasetLinkI()
        pdl2.setParent(pr1)
        pdl2.setChild(ds2)
        update.saveObject(pdl2)

        pdl3 = ProjectDatasetLinkI()
        pdl3.setParent(pr2)
        pdl3.setChild(ds2)
        update.saveObject(pdl3)

        dil4 = DatasetImageLinkI()
        dil4.setParent(ds1)
        dil4.setChild(im2)
        update.saveObject(dil4)

        dil5 = DatasetImageLinkI()
        dil5.setParent(ds2)
        dil5.setChild(im2)
        update.saveObject(dil5)

        dil6 = DatasetImageLinkI()
        dil6.setParent(ds3)
        dil6.setChild(im2)
        update.saveObject(dil6)

        #test:
        hier = pojos.findContainerHierarchies("Project", [long(im2.id.val)],
                                              None)

        self.assertEquals(3, len(hier),
                          "len of hier != 3: %s" % [type(x) for x in hier])
        for c in hier:
            if c.id.val == pr1.id.val and isinstance(c, ProjectI):
                self.assert_(c.sizeOfDatasetLinks() == 2,
                             "length 2 != " + str(c.sizeOfDatasetLinks()))
                for pdl in c.copyDatasetLinks():
                    self.assert_(pdl.child.sizeOfImageLinks() == 1)
                    for dil in pdl.child.copyImageLinks():
                        self.assert_(dil.child.id.val == im2.id.val)
            elif c.id.val == pr2.id.val and isinstance(c, ProjectI):
                self.assert_(c.sizeOfDatasetLinks() == 1)
            elif c.id.val == ds3.id.val and isinstance(c, DatasetI):
                self.assert_(c.sizeOfImageLinks() == 1)
예제 #59
0
    def test1071_1(self):
        admin = self.root.sf.getAdminService()

        common_group = self.new_group(perms="rwrw--")
        c1 = self.new_client(common_group)
        c2 = self.new_client(common_group)

        c1_pojos = c1.sf.getContainerService()
        c1_query = c1.sf.getQueryService()
        c1_update = c1.sf.getUpdateService()
        c1_uuid = c1.sf.getAdminService().getEventContext().sessionUuid

        c2_pojos = c2.sf.getContainerService()
        c2_query = c2.sf.getQueryService()
        c2_update = c2.sf.getUpdateService()
        c2_uuid = c2.sf.getAdminService().getEventContext().sessionUuid

        #projects
        pr1 = ProjectI()
        pr1.setName(rstring('test1071-pr1-%s' % (c1_uuid)))
        pr1 = c1_update.saveAndReturnObject(pr1)
        pr1.unload()

        pr2 = ProjectI()
        pr2.setName(rstring('test1071-pr2-%s' % (c2_uuid)))
        pr2 = c2_update.saveAndReturnObject(pr2)
        pr2.unload()

        #datasets
        ds1 = DatasetI()
        ds1.setName(rstring('test1071-ds1-%s' % (c1_uuid)))
        ds1 = c1_update.saveAndReturnObject(ds1)
        ds1.unload()

        ds2 = DatasetI()
        ds2.setName(rstring('test1071-ds2-%s' % (c2_uuid)))
        ds2 = c2_update.saveAndReturnObject(ds2)
        ds2.unload()

        #images
        im2 = ImageI()
        im2.setName(rstring('test1071-im2-%s' % (c2_uuid)))
        im2.acquisitionDate = rtime(0)
        im2 = c2_update.saveAndReturnObject(im2)
        im2.unload()

        #links
        # im2 owned by u2
        #
        # im2   -> ds2 --> pr2 (owned by u2)
        #      |
        #      \-> ds1 --> pr1 (owned by u1)
        #
        pdl1 = ProjectDatasetLinkI()
        pdl1.setParent(pr1)
        pdl1.setChild(ds1)
        c1_update.saveObject(pdl1)

        pdl2 = ProjectDatasetLinkI()
        pdl2.setParent(pr2)
        pdl2.setChild(ds2)
        c2_update.saveObject(pdl2)

        dil2 = DatasetImageLinkI()
        dil2.setParent(ds2)
        dil2.setChild(im2)
        c2_update.saveObject(dil2)

        dil1 = DatasetImageLinkI()
        dil1.setParent(ds1)
        dil1.setChild(im2)
        c1_update.saveObject(dil1)

        #test:
        hier = c2_pojos.findContainerHierarchies("Project", [long(im2.id.val)],
                                                 None)

        self.assertEquals(2, len(hier),
                          "size of hier != 2: %s" % [type(x) for x in hier])
        for c in hier:
            if c.id.val == pr1.id.val and isinstance(c, ProjectI):
                self.assertEquals(1, c.sizeOfDatasetLinks())
                for pdl in c.copyDatasetLinks():
                    self.assertEquals(1, pdl.child.sizeOfImageLinks())
                    for dil in pdl.child.copyImageLinks():
                        self.assert_(dil.child.id.val == im2.id.val)
            elif c.id.val == pr2.id.val and isinstance(c, ProjectI):
                self.assertEquals(1, c.sizeOfDatasetLinks())
            elif c.id.val == ds3.id.val and isinstance(c, DatasetI):
                self.assertEquals(1, c.sizeOfImageLinks())