How to configure tests for OMERO.web apps using IWebTest in omeroweb.testlib

I’m creating an app for OMERO.web and I wish to test URLs that say return JSON or html. There doesn’t seem to be much documentation on testing besides this one. How do you configure tests for apps?

My URLs require the login_required decorator from the omeroweb.webclient.decorators module, and is run with DJANGO_SETTINGS_MODULE=omeroweb.settings pytest tests/test_views.py. I’m getting the omero.ClientError “No host specified. Use omero.client(HOSTNAME), ICE_CONFIG, or similar.”

import pytest
import omero

from django.core.urlresolvers import reverse

from omeroweb.testlib import IWebTest
from omeroweb.testlib import get, post, get_json
from aimviewer.config import (TEST_DATASET, TEST_IMAGE_1)
import aimviewer.views as views


class TestView(IWebTest):

    def test_get_image_nav(self):
        new_user = self.new_user()
        omeName = new_user.omeName.val
        django_client = self.new_django_client(omeName, omeName)
        request_url = reverse(views.get_image_nav,
                kwargs={'dataset_id': TEST_DATASET,
                        'image_id': TEST_IMAGE_1})
        rsp = get_json(django_client, request_url)
        print(rsp)

Apologies for the delay - we seem to have missed your post.

I have a PR open to improve the testing documentation:

I think you need to specify ICE_CONFIG to point to the file at


which contains e.g. omero.host=localhost

export ICE_CONFIG=/path/to/openmicroscopy/etc/ice.config 

Hope that helps,

Will.