Stack Trace
self = <test.integration.gatewaytest.test_get_objects.TestGetObject object at 0x7f5f4cecec50>
def testGetObjectsAnnotation(self):
# create new group and user - don't rely on existing test user/group
group = self.new_group(perms='rwra--')
client, user = self.new_client_and_user(group=group)
conn = BlitzGateway(client_obj=client)
update = conn.getUpdateService()
ns = "test_get_objects_annotation_comment"
ns_tag = "test_get_objects_annotation_tag"
ns_file = "test_get_objects_annotation_file"
def create_dataset_with_annotations(name, dtype="Dataset"):
if dtype == "Dataset":
obj = DatasetI()
obj.name = rstring(name)
obj = update.saveAndReturnObject(obj)
wrapper = omero.gateway.DatasetWrapper(conn, obj)
elif dtype == "Project":
obj = ProjectI()
obj.name = rstring(name)
obj = update.saveAndReturnObject(obj)
wrapper = omero.gateway.ProjectWrapper(conn, obj)
# create Comment
ann = omero.gateway.CommentAnnotationWrapper(conn)
ann.setNs(ns)
ann.setValue("Test Comment: " + name)
ann = wrapper.linkAnnotation(ann)
# create Tag
tag = omero.gateway.TagAnnotationWrapper(conn)
tag.setNs(ns_tag)
tag.setValue("Test Tag: " + name)
wrapper.linkAnnotation(tag)
# create FileAnnotation
fileAnn = omero.gateway.FileAnnotationWrapper(conn)
fileObj = omero.model.OriginalFileI()
fileObj = omero.gateway.OriginalFileWrapper(conn, fileObj)
fileObj.setName(omero.rtypes.rstring('fileName'))
fileObj.setPath(omero.rtypes.rstring('path/to/file'))
fileObj.setHash(omero.rtypes.rstring('a'))
fileObj.setSize(omero.rtypes.rlong(0))
fileObj.save()
fileAnn.setFile(fileObj)
fileAnn.setNs(ns_file)
fileAnn.save()
wrapper.linkAnnotation(fileAnn)
return wrapper
dataset1 = create_dataset_with_annotations("Dataset 1")
dataset2 = create_dataset_with_annotations("Dataset 2")
create_dataset_with_annotations("Project 1", dtype="Project")
# get all annotations on one Dataset
annGen = conn.getObjects("Annotation",
opts={'parent_type': "dataset",
'parent_ids': [dataset1.id]})
assert len(list(annGen)) == 3
# get all annotations on two Datasets
annGen = conn.getObjects("Annotation",
opts={'parent_type': "dataset",
'parent_ids': [dataset1.id,
dataset2.id]})
assert len(list(annGen)) == 6
# get all annotations on ALL Datasets
annGen = conn.getObjects("Annotation", opts={'parent_type': "dataset"})
assert len(list(annGen)) == 6
# No annotations on PlateAcquisition (none created)
annGen = conn.getObjects("Annotation",
opts={'parent_type': "plateacquisition"})
assert len(list(annGen)) == 0
# get ALL annotations
anns = list(conn.getObjects("Annotation"))
> assert len(anns) == 9
E assert 11 == 9
E + where 11 = len([<FileAnnotationWrapper id=365>, <FileAnnotationWrapper id=366>, <CommentAnnotationWrapper id=5328>, <TagAnnotationWrapper id=5329>, <FileAnnotationWrapper id=5330>, <CommentAnnotationWrapper id=5331>, ...])
test/integration/gatewaytest/test_get_objects.py:720: AssertionError