Table Of Contents

Previous topic

omero.sys package

Next topic

omero.util package

This Page

omero.testlib package

Module contents

Library for integration tests

class omero.testlib.AbstractRepoTest

Bases: omero.testlib.ITest

all(client)
assert_dir_write(mrepo2, dirname)
assert_error(cb, loops=10, wait=500)
assert_import(client, proc, folder)
assert_listings(mrepo1, unique_dir)
assert_no_dir_write(mrepo2, dirname)
assert_no_read(mrepo2, filename, ofile)
assert_no_write(mrepo2, filename, ofile)
assert_passes(cb, loops=10, wait=500)
assert_read(mrepo2, filename, ofile, ctx=None)
assert_write(mrepo2, filename, ofile)
create_file(mrepo1, filename)
create_fileset(folder)
create_settings()
create_test_dir()
full_import(client)

Re-usable method for a basic import

get_managed_repo(client=None)
raw(command, args, client=None)
setup_method(method)
test_dir(client=None)
upload_folder(proc, folder)
user_dir(client=None)
class omero.testlib.Clients

Bases: object

add(client)
class omero.testlib.ITest

Bases: object

DEFAULT_GROUP_OWNER = False
DEFAULT_PERMS = 'rw----'
classmethod add_experimenters(group, experimenters)
add_groups(experimenter, groups, owner=False)
change_group(obj, target, client=None)

Moves a list of model entities (ProjectI, DatasetI or ImageI) to the target group. Accepts a client instance to guarantee calls in correct user contexts. Creates Chgrp2 commands and calls do_submit().

Parameters:
  • obj – a list of objects to be moved
  • target – the ID of the target group
  • client – user context
change_permissions(gid, perms, client=None)

Changes the permissions of an ExperimenterGroup object. Accepts a client instance to guarantee calls in correct user contexts. Creates Chmod2 commands and calls do_submit().

Parameters:
  • gid – id of an ExperimenterGroup
  • perms – permissions string
  • client – user context
create_datasets(count, base_name, client=None)

Creates a list of the given number of Dataset instances with names of the form “name [1]”, “name [2]” etc and returns them in a list. :param count: The number of datasets to create :param description: The base name of the dataset :param client: The client to use to create the object

create_pixels(x=10, y=10, z=10, c=3, t=50, pixels_type='int8', client=None)

Creates an int8 pixel of the given size in the database. No data is written.

create_test_image(size_x=16, size_y=16, size_z=1, size_c=1, size_t=1, session=None, name='testImage', thumb=True)

Creates a test image of the required dimensions, where each pixel value is set to the value of x+y. Returns the image (ImageI)

delete(objs)

Deletes model entities (ProjectI, DatasetI, ImageI, etc) by creating Delete2 commands and calling do_submit().

Parameters:obj – a list of objects to be deleted
do_submit(request, client, test_should_pass=True, omero_group=None)

Performs the request(s), waits on completion and checks that the result is not an error. The request can either be a single command or a list of commands. If the latter then the request list will be wrapped in a DoAll.

get_fileset(i, client=None)

Takes an image object and return a fileset object

classmethod get_pixels_type(pixels_type)
classmethod group_and_name(group)
import_fake_file(images_count=1, name=None, client=None, with_companion=False, skip='all', **kwargs)

Creates a fake file with an images_count of images, imports the file and then return the list of images. By default a single image is imported.

import_image(filename=None, client=None, extra_args=None, skip='all', **kwargs)

Imports the specified file.

import_plates(client=None, plates=1, plate_acqs=1, plate_cols=1, plate_rows=1, fields=1, **kwargs)

Creates fake plates and imports them.

index(*objs)
keep_root_alive()

Keeps root connection alive.

Links two linkable model entities together by creating an instance of the correct link entity (e.g. ProjectDatasetLinkI) and persisting it in the DB. Accepts client instance to allow calls to happen in correct user contexts. Currently support links are:

  • project/dataset
  • dataset/image
  • image/annotation
Parameters:
  • obj1 – parent object
  • obj2 – child object
  • client – The client to use to create the link
log = <logging.Logger instance at 0x33ac8f38>
classmethod login_args(client=None)
login_attempt(name, t, pw='BAD', less=False)

Checks that login happens in less than or greater than the given time. By default, the password “BAD” is used, and the expectation is that login will take greather than the specified time since the password won’t match. To check that logins happen more quickly, pass the correct password and less=True:

login_attempt(“user”, 0.15, pw=”REALVALUE”, less=True)

See integration.tickets4000 and 5000

make_dataset(name=None, description=None, client=None)

Creates a new dataset instance and returns the persisted object. :param name: The dataset name. If None, a UUID string will be used :param description: The dataset description :param client: The client to use to create the object

make_file_annotation(name=None, binary=None, mimetype=None, client=None, namespace=None)

Creates a file annotation with an original file. If no name has been provided, a UUID string shall be used.

Parameters:
  • name – The name of the file
  • binary – The binary data
  • mimetype – The mimetype of the file.
  • client – The client to use to create the object
  • ns – The namespace for the annotation
make_image(name=None, description=None, date=0, client=None)

Creates a new image instance and returns the persisted object. :param name: The image name. If None, a UUID string will be used :param description: The image description :param date: The image acquisition date :param client: The client to use to create the object

make_project(name=None, description=None, client=None)

Creates a new project instance and returns the persisted object. :param name: The project name. If None, a UUID string will be used :param description: The project description :param client: The client to use to create the object

make_tag(name=None, client=None, ns=None)

Creates a new tag instance and returns the persisted object. :param name: The tag name. If None, a UUID string will be used :param client: The client to use to create the object :param ns: The namespace for the annotation. If None, do not set.

missing_pyramid(client=None)

Creates and returns a pixels whose shape changes from 1,1,4000,4000,1 to 4000,4000,1,1,1 making it a pyramid candidate but without the pyramid which is created on initial import in 4.3+. This simulates a big image that was imported in 4.2.

new_client(group=None, user=None, perms=None, owner=False, system=False, session=None, password=None, email=None)

Like new_user() but returns an active client.

Passing user= or session= will prevent self.new_user from being called, and instead the given user (by name or ExperimenterI) or session will be logged in.

new_client_and_user(group=None, perms=None, owner=False, system=False)
new_dataset(name=None, description=None)

Creates a new dataset object. :param name: The dataset name. If None, a UUID string will be used :param description: The dataset description

classmethod new_group(experimenters=None, perms=None, config=None, gname=None)
new_image(name=None, description=None, date=0)

Creates a new image object. If no name has been provided, a UUID string shall be used. :param name: The image name. If None, a UUID string will be used :param description: The image description :param date: The image acquisition date

new_object(classname, name=None, description=None)
new_project(name=None, description=None)

Creates a new project object. :param name: The project name. If None, a UUID string will be used :param description: The project description

new_tag(name=None, ns=None)

Creates a new tag object. :param name: The tag name. If None, a UUID string will be used :param ns: The namespace for the annotation. If None, do not set.

classmethod new_user(group=None, perms=None, owner=False, system=False, uname=None, email=None)
Owner:If user is to be an owner of the created group
System:If user is to be a system admin
classmethod omerodistdir()
remove_experimenters(group, experimenters)
classmethod root_login_args()
set_context(client, gid)
classmethod setup_class()
skip_if(config_key, condition, message=None)

Skip test if configuration does not meet condition

classmethod teardown_class()
timeit(func, *args, **kwargs)
tmpfile()
classmethod user_and_name(user)
classmethod uuid()
wait_on_cmd(client, handle, loops=10, ms=500, passes=True)

Wait on an omero.cmd.HandlePrx to finish processing and then assert pass or fail. The callback is returned for accessing the Response and Status elements.

write(pixels, rps, pixels_type='int8')

Writes byte arrays consisting of [5] to as either planes or tiles depending on the pixel size.

omero.testlib.PF

alias of ProjectionFixture

class omero.testlib.ProjectionFixture(perms, writer, reader, can_read, can_annotate=False, can_delete=False, can_edit=False, can_link=False)

Bases: object

Used to test the return values from:
‘select x.permissions from Object x’
get_name()