<!DOCTYPE html> <html class="writer-html5" lang="en" > <head> <meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Running and writing tests — OMERO documentation</title> <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> <!--[if lt IE 9]> <script src="../_static/js/html5shiv.min.js"></script> <![endif]--> <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script> <script src="../_static/jquery.js"></script> <script src="../_static/underscore.js"></script> <script src="../_static/_sphinx_javascript_frameworks_compat.js"></script> <script src="../_static/doctools.js"></script> <script src="../_static/sphinx_highlight.js"></script> <script src="../_static/js/theme.js"></script> <link rel="index" title="Index" href="../genindex.html" /> <link rel="search" title="Search" href="../search.html" /> <link rel="next" title="OMERO Python language bindings" href="Python.html" /> <link rel="prev" title="Working with OMERO" href="GettingStarted.html" /> </head> <body class="wy-body-for-nav"> <div class="wy-grid-for-nav"> <nav data-toggle="wy-nav-shift" class="wy-nav-side"> <div class="wy-side-scroll"> <div class="wy-side-nav-search" > <a href="../index.html" class="icon icon-home"> OMERO </a> <div class="version"> 5.6 </div> <div role="search"> <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> <input type="text" name="q" placeholder="Search docs" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> </div> </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> <ul class="current"> <li class="toctree-l1"><a class="reference internal" href="../users/index.html">OMERO Overview and CLI User Documentation</a></li> <li class="toctree-l1"><a class="reference internal" href="../sysadmins/index.html">System Administrator Documentation</a></li> <li class="toctree-l1 current"><a class="reference internal" href="index.html">Developer Documentation</a><ul class="current"> <li class="toctree-l2 current"><a class="reference internal" href="index.html#introduction-to-omero">Introduction to OMERO</a><ul class="current"> <li class="toctree-l3"><a class="reference internal" href="whatsnew.html">What’s new for OMERO 5.6 for developers</a></li> <li class="toctree-l3"><a class="reference internal" href="python3-migration.html">Migration from OMERO 5.5 (Python 2) to OMERO 5.6 (Python 3)</a></li> <li class="toctree-l3"><a class="reference internal" href="installation.html">Installing OMERO from source</a></li> <li class="toctree-l3"><a class="reference internal" href="build-system.html">Build System</a></li> <li class="toctree-l3"><a class="reference internal" href="GettingStarted.html">Working with OMERO</a></li> <li class="toctree-l3 current"><a class="current reference internal" href="#">Running and writing tests</a><ul> <li class="toctree-l4"><a class="reference internal" href="#running-tests">Running tests</a></li> <li class="toctree-l4"><a class="reference internal" href="#writing-tests">Writing tests</a></li> </ul> </li> </ul> </li> <li class="toctree-l2"><a class="reference internal" href="index.html#using-the-omero-api">Using the OMERO API</a></li> <li class="toctree-l2"><a class="reference internal" href="index.html#analysis">Analysis</a></li> <li class="toctree-l2"><a class="reference internal" href="index.html#scripts-plugins-for-omero">Scripts - plugins for OMERO</a></li> <li class="toctree-l2"><a class="reference internal" href="index.html#web">Web</a></li> <li class="toctree-l2"><a class="reference internal" href="index.html#insight">Insight</a></li> <li class="toctree-l2"><a class="reference internal" href="index.html#more-on-api-usage">More on API Usage</a></li> <li class="toctree-l2"><a class="reference internal" href="index.html#the-ome-data-model">The OME Data Model</a></li> <li class="toctree-l2"><a class="reference internal" href="index.html#searching">Searching</a></li> <li class="toctree-l2"><a class="reference internal" href="index.html#authentication-and-security">Authentication and Security</a></li> <li class="toctree-l2"><a class="reference internal" href="index.html#omero-server-in-depth">OMERO.server in depth</a></li> </ul> </li> </ul> </div> </div> </nav> <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > <i data-toggle="wy-nav-top" class="fa fa-bars"></i> <a href="../index.html">OMERO</a> </nav> <div class="wy-nav-content"> <div class="rst-content"> <div role="navigation" aria-label="Page navigation"> <ul class="wy-breadcrumbs"> <li><a href="../index.html" class="icon icon-home"></a></li> <li class="breadcrumb-item"><a href="index.html">Developer Documentation</a></li> <li class="breadcrumb-item active">Running and writing tests</li> <li class="wy-breadcrumbs-aside"> <a href="../_sources/developers/testing.rst.txt" rel="nofollow"> View page source</a> </li> </ul> <hr/> </div> <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> <div itemprop="articleBody"> <section id="running-and-writing-tests"> <h1>Running and writing tests<a class="headerlink" href="#running-and-writing-tests" title="Permalink to this heading">ïƒ</a></h1> <p>The following guidelines apply to tests in both the Java and Python test components. However, some of the presented options apply to only one or the other.</p> <p>The default build target does not compile all the required testing resources. You should run <cite>test-compile</cite> (or <cite>build-dev</cite> if you are using Eclipse) first:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">./</span><span class="n">build</span><span class="o">.</span><span class="n">py</span> <span class="n">build</span><span class="o">-</span><span class="n">default</span> <span class="n">test</span><span class="o">-</span><span class="nb">compile</span> </pre></div> </div> <p>You must rebuild the <cite>test-compile</cite> target if you subsequently modify any of the Java tests.</p> <div class="admonition note"> <p class="admonition-title">Note</p> <p>The OMERO C++ components and tests are under heavy development, and are not compiled or run by the targets mentioned on this page.</p> </div> <section id="running-tests"> <h2>Running tests<a class="headerlink" href="#running-tests" title="Permalink to this heading">ïƒ</a></h2> <section id="running-unit-tests"> <h3>Running unit tests<a class="headerlink" href="#running-unit-tests" title="Permalink to this heading">ïƒ</a></h3> <p>Starting from version 5.5, components have been migrated to their own repository.</p> <dl class="simple"> <dt>The following repositories use <a class="reference external" href="https://gradle.org/">Gradle</a> to run the unit tests:</dt><dd><ul class="simple"> <li><p><a class="reference external" href="https://github.com/ome/omero-model">https://github.com/ome/omero-model</a></p></li> <li><p><a class="reference external" href="https://github.com/ome/omero-common">https://github.com/ome/omero-common</a></p></li> <li><p><a class="reference external" href="https://github.com/ome/omero-romio">https://github.com/ome/omero-romio</a></p></li> <li><p><a class="reference external" href="https://github.com/ome/omero-renderer">https://github.com/ome/omero-renderer</a></p></li> <li><p><a class="reference external" href="https://github.com/ome/omero-server">https://github.com/ome/omero-server</a></p></li> <li><p><a class="reference external" href="https://github.com/ome/omero-blitz">https://github.com/ome/omero-blitz</a></p></li> <li><p><a class="reference external" href="https://github.com/ome/omero-gateway-java">https://github.com/ome/omero-gateway-java</a></p></li> </ul> </dd> <dt>The following repositories use <a class="reference external" href="https://docs.pytest.org/en/latest/">pytest</a> to run the unit tests:</dt><dd><ul class="simple"> <li><p><a class="reference external" href="https://github.com/ome/omero-py">https://github.com/ome/omero-py</a></p></li> <li><p><a class="reference external" href="https://github.com/ome/omero-web">https://github.com/ome/omero-web</a></p></li> </ul> </dd> </dl> </section> <section id="running-integration-tests"> <h3>Running integration tests<a class="headerlink" href="#running-integration-tests" title="Permalink to this heading">ïƒ</a></h3> <p>Integration testing is a bit more complex because of the reliance on a database, which is not easily mockable. All Hibernate-related classes are tested in integration mode.</p> <p>The tests require a fast computer. Running all the integration tests places several restrictions on the environment:</p> <ul class="simple"> <li><p>There must be a running OMERO database.</p></li> <li><p>An OMERO.server instance must be running.</p></li> </ul> <p>Integration tests assume that:</p> <ul class="simple"> <li><p><span class="target" id="index-0"></span><code class="xref std std-envvar docutils literal notranslate"><span class="pre">ICE_CONFIG</span></code> has been properly set. The contents of the <code class="file docutils literal notranslate"><span class="pre">etc/ice.config</span></code> file should be enough to configure a running server for integration testing. This means that code creating a client connection as outlined in <a class="reference internal" href="GettingStarted/AdvancedClientDevelopment.html"><span class="doc">Developing OMERO clients</span></a> should execute without errors.</p></li> <li><p>An OMERO.server instance is running on the host and port specified in the <span class="target" id="index-1"></span><code class="xref std std-envvar docutils literal notranslate"><span class="pre">ICE_CONFIG</span></code> file.</p></li> </ul> <p>If any of the tests fail with a user authentication exception (or <code class="docutils literal notranslate"><span class="pre">omero.client</span></code> throws an exception), a new <code class="file docutils literal notranslate"><span class="pre">ice.config</span></code> file can be created and pointed to by the <span class="target" id="index-2"></span><code class="xref std std-envvar docutils literal notranslate"><span class="pre">ICE_CONFIG</span></code> environment variable. Most likely the first settings that will have to be put there will be <code class="docutils literal notranslate"><span class="pre">omero.user</span></code> and <code class="docutils literal notranslate"><span class="pre">omero.pass</span></code>.</p> <section id="running-all-tests"> <h4>Running all tests<a class="headerlink" href="#running-all-tests" title="Permalink to this heading">ïƒ</a></h4> <p>To run all the integration tests, use</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">./</span><span class="n">build</span><span class="o">.</span><span class="n">py</span> <span class="n">test</span><span class="o">-</span><span class="n">integration</span> </pre></div> </div> <p>Note that some Python tests are excluded by default, see <a class="reference internal" href="#using-markers-in-python-tests"><span class="std std-ref">Using markers in OmeroPy tests</span></a> for more details.</p> </section> <section id="component-tests"> <h4>Component tests<a class="headerlink" href="#component-tests" title="Permalink to this heading">ïƒ</a></h4> <p>Running an integration test suite for an individual component can be done explicitly via:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">./</span><span class="n">build</span><span class="o">.</span><span class="n">py</span> <span class="o">-</span><span class="n">f</span> <span class="n">components</span><span class="o">/<</span><span class="n">component</span><span class="o">>/</span><span class="n">build</span><span class="o">.</span><span class="n">xml</span> <span class="n">integration</span> </pre></div> </div> <p>Results are placed in <code class="docutils literal notranslate"><span class="pre">components/<component>/target/reports</span></code>.</p> </section> <section id="individual-tests"> <h4>Individual tests<a class="headerlink" href="#individual-tests" title="Permalink to this heading">ïƒ</a></h4> <div class="admonition warning"> <p class="admonition-title">Warning</p> <p>Some integration tests leak file descriptors. If many tests are run then they may start to fail after the system’s open files limit is reached. Depending on your system the limit may be checked or adjusted using <strong class="command">ulimit -n</strong> and <code class="file docutils literal notranslate"><span class="pre">/etc/login.conf</span></code> or <code class="file docutils literal notranslate"><span class="pre">/etc/security/limits.conf</span></code>.</p> </div> </section> </section> <section id="running-java-tests"> <h3>Running Java tests<a class="headerlink" href="#running-java-tests" title="Permalink to this heading">ïƒ</a></h3> <section id="id1"> <h4>Individual tests<a class="headerlink" href="#id1" title="Permalink to this heading">ïƒ</a></h4> <p>Alternatively, you can run individual tests which you may currently be working on using the <code class="docutils literal notranslate"><span class="pre">--tests</span></code> parameter. The test class must be provided in the fully qualified name form.</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">cd</span> <span class="n">components</span><span class="o">/</span><span class="n">tools</span><span class="o">/</span><span class="n">OmeroJava</span> <span class="n">gradle</span> <span class="n">test</span> <span class="o">--</span><span class="n">tests</span> <span class="s2">"integration.gateway.AdminFacilityTest"</span> </pre></div> </div> </section> <section id="individual-test-class-methods"> <h4>Individual test class methods<a class="headerlink" href="#individual-test-class-methods" title="Permalink to this heading">ïƒ</a></h4> <p>Individual OmeroJava test class methods can be run using the <code class="docutils literal notranslate"><span class="pre">--tests</span></code> parameter. The test method must be provided in the fully qualified name form.</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">cd</span> <span class="n">components</span><span class="o">/</span><span class="n">tools</span><span class="o">/</span><span class="n">OmeroJava</span> <span class="n">gradle</span> <span class="n">test</span> <span class="o">--</span><span class="n">tests</span> <span class="s2">"integration.chgrp.AnnotationMoveTest.testMoveTaggedImage"</span> </pre></div> </div> </section> <section id="individual-test-groups"> <h4>Individual test groups<a class="headerlink" href="#individual-test-groups" title="Permalink to this heading">ïƒ</a></h4> <p>To run individual OmeroJava test groups the <code class="docutils literal notranslate"><span class="pre">--tests</span></code> parameter.</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">cd</span> <span class="n">components</span><span class="o">/</span><span class="n">tools</span><span class="o">/</span><span class="n">OmeroJava</span> <span class="n">gradle</span> <span class="n">test</span> <span class="o">--</span><span class="n">tests</span> <span class="s2">"integration.*"</span> </pre></div> </div> </section> <section id="using-eclipse-to-run-tests"> <h4>Using Eclipse to run tests<a class="headerlink" href="#using-eclipse-to-run-tests" title="Permalink to this heading">ïƒ</a></h4> <p>To facilitate importing OMERO components into Eclipse, there are <code class="file docutils literal notranslate"><span class="pre">.project</span></code> and <code class="file docutils literal notranslate"><span class="pre">.classpath-template</span></code> files stored in each component directory (e.g. <code class="file docutils literal notranslate"><span class="pre">tools/OmeroJava</span></code>’s <code class="file docutils literal notranslate"><span class="pre">.project</span></code> and <code class="file docutils literal notranslate"><span class="pre">.classpath-template</span></code>).</p> <p>There are also top-level <code class="file docutils literal notranslate"><span class="pre">.classpath</span></code> and <code class="file docutils literal notranslate"><span class="pre">.project</span></code> files which allow for importing all components as a single project, but this approach requires more memory and does not clearly differentiate the classpaths, and so can lead to confusion.</p> <p>Before importing any component as a project into Eclipse, a successful build has to have taken place:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">./</span><span class="n">build</span><span class="o">.</span><span class="n">py</span> </pre></div> </div> <p>This is for two reasons. Firstly, the Eclipse projects are not configured to perform the code generation needed. The <strong class="command">build.py</strong> command creates the directory:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o"><</span><span class="n">component</span><span class="o">>/</span><span class="n">target</span> </pre></div> </div> <p>which will be missing from any Eclipse project you open before building the source.</p> <p>Secondly, Ivy is used to copy all the jar dependencies from <code class="docutils literal notranslate"><span class="pre">OMERO_SOURCE_PREFIX/lib/repository</span></code> to <code class="docutils literal notranslate"><span class="pre"><component>/target/libs</span></code>, which is then used in the Eclipse <code class="file docutils literal notranslate"><span class="pre">.classpath</span></code> files.</p> <p>If Eclipse ever gets out of sync after the first build, <strong class="command">./build.py build-eclipse</strong> can be used to quickly synchronize.</p> <p>A prerequisite of running unit and integration tests in the Eclipse UI is having the TestNG plug-in installed and working (help available on the <a class="reference external" href="https://testng.org/doc/eclipse.html">TestNG site</a>).</p> <p>Running the unit tests under Eclipse requires no extra settings and is as easy as navigating to the package or class context menu <span class="guilabel">Run As</span> or <span class="guilabel">Debug As</span>, then selecting <span class="guilabel">TestNG</span>.</p> <p>Integration tests require the <span class="target" id="index-3"></span><code class="xref std std-envvar docutils literal notranslate"><span class="pre">ICE_CONFIG</span></code> environment variable to be available for the Eclipse-controlled JVM. This can be done by editing Debug/Run configurations in Eclipse. After navigating to the Debug (or Run) Configurations window, the <span class="guilabel">Environment</span> tab needs to be selected. After clicking <span class="guilabel">New</span>, <span class="target" id="index-4"></span><code class="xref std std-envvar docutils literal notranslate"><span class="pre">ICE_CONFIG</span></code> can be defined as a path to the <code class="file docutils literal notranslate"><span class="pre">ice.config</span></code> file. This setting needs to be defined per package, class or method.</p> <p>By using the “debug†target from templates.xml, it is possible to have OMERO listen on port 8787 for a debugging connection.</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">omero</span> <span class="n">admin</span> <span class="n">stop</span> <span class="n">omero</span> <span class="n">admin</span> <span class="n">start</span> <span class="n">debug</span> </pre></div> </div> <p>Then in Eclipse, you can create a new “Debug†configuration by clicking on <span class="guilabel">Remote Java Application</span>, and setting the port to 8787. These values are arbitrary and can be changed locally.</p> <p><strong>Keep in mind</strong>:</p> <ul class="simple"> <li><p>The server will not start up until you have connected with Eclipse. This is due to the “suspend=y†clause in templates.xml. If you would like the server to start without you connecting, use “suspend=nâ€.</p></li> <li><p>If you take too much time examining your threads, your calls may throw timeout exceptions.</p></li> </ul> </section> </section> <section id="running-python-tests"> <h3>Running Python tests<a class="headerlink" href="#running-python-tests" title="Permalink to this heading">ïƒ</a></h3> <section id="using-markers-in-omeropy-tests"> <span id="using-markers-in-python-tests"></span><h4>Using markers in OmeroPy tests<a class="headerlink" href="#using-markers-in-omeropy-tests" title="Permalink to this heading">ïƒ</a></h4> <p>Tests under OmeroPy can be included or excluded according to markers defined in the tests. This can be done by using the <code class="docutils literal notranslate"><span class="pre">-DMARK</span></code> option. For example, to run all the integration tests marked as <code class="docutils literal notranslate"><span class="pre">broken</span></code>:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">./</span><span class="n">build</span><span class="o">.</span><span class="n">py</span> <span class="o">-</span><span class="n">f</span> <span class="n">components</span><span class="o">/</span><span class="n">tools</span><span class="o">/</span><span class="n">OmeroPy</span><span class="o">/</span><span class="n">build</span><span class="o">.</span><span class="n">xml</span> <span class="n">integration</span> <span class="o">-</span><span class="n">DMARK</span><span class="o">=</span><span class="n">broken</span> </pre></div> </div> <p>By default tests marked as <code class="docutils literal notranslate"><span class="pre">broken</span></code> are excluded so the following two builds are equivalent:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">./</span><span class="n">build</span><span class="o">.</span><span class="n">py</span> <span class="o">-</span><span class="n">f</span> <span class="n">components</span><span class="o">/</span><span class="n">tools</span><span class="o">/</span><span class="n">OmeroPy</span><span class="o">/</span><span class="n">build</span><span class="o">.</span><span class="n">xml</span> <span class="n">integration</span> <span class="o">./</span><span class="n">build</span><span class="o">.</span><span class="n">py</span> <span class="o">-</span><span class="n">f</span> <span class="n">components</span><span class="o">/</span><span class="n">tools</span><span class="o">/</span><span class="n">OmeroPy</span><span class="o">/</span><span class="n">build</span><span class="o">.</span><span class="n">xml</span> <span class="n">integration</span> <span class="o">-</span><span class="n">DMARK</span><span class="o">=</span><span class="s2">"not broken"</span> </pre></div> </div> <p>In order to run <strong>all</strong> tests, including <code class="docutils literal notranslate"><span class="pre">broken</span></code>, an empty marker must be used:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">./</span><span class="n">build</span><span class="o">.</span><span class="n">py</span> <span class="o">-</span><span class="n">f</span> <span class="n">components</span><span class="o">/</span><span class="n">tools</span><span class="o">/</span><span class="n">OmeroPy</span><span class="o">/</span><span class="n">build</span><span class="o">.</span><span class="n">xml</span> <span class="n">integration</span> <span class="o">-</span><span class="n">DMARK</span><span class="o">=</span> </pre></div> </div> <div class="admonition seealso"> <p class="admonition-title">See also</p> <p><a class="reference internal" href="#marking-python-tests"><span class="std std-ref">Marking OmeroPy tests</span></a></p> </div> </section> <section id="running-tests-directly"> <span id="running-python-tests-directly"></span><h4>Running tests directly<a class="headerlink" href="#running-tests-directly" title="Permalink to this heading">ïƒ</a></h4> <p>When writing tests it can be more convenient, flexible and powerful to run the tests from <a class="reference external" href="https://github.com/ome/openmicroscopy/tree/develop/components/tools/OmeroPy">https://github.com/ome/openmicroscopy/tree/develop/components/tools/OmeroPy</a> or <a class="reference external" href="https://github.com/ome/openmicroscopy/tree/develop/components/tools/OmeroWeb">https://github.com/ome/openmicroscopy/tree/develop/components/tools/OmeroWeb</a> using <strong class="program">pytest</strong>. Since Python is interpreted, tests can be written and then run without having to rebuild or restart the server. A few basic options are shown below.</p> <p>First create a python virtual environment as described on the <a class="reference internal" href="Python.html"><span class="doc">OMERO Python</span></a> page, including <code class="docutils literal notranslate"><span class="pre">omero-py</span></code> and <code class="docutils literal notranslate"><span class="pre">omero-web</span></code> if you want to run OmeroWeb tests. Some tests also require the installation of PyTables.</p> <p>Then install some additional test dependencies:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ pip install pytest pytest-mock pyyaml tables # for Omeroweb tests $ pip install pytest-django </pre></div> </div> <p>Run tests directly with pytest, setting the <span class="target" id="index-5"></span><code class="xref std std-envvar docutils literal notranslate"><span class="pre">ICE_CONFIG</span></code> as described above. Also set <span class="target" id="index-6"></span><code class="xref std std-envvar docutils literal notranslate"><span class="pre">OMERODIR</span></code> to point to the OMERO.server:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">export</span> <span class="n">ICE_CONFIG</span><span class="o">=/</span><span class="n">path</span><span class="o">/</span><span class="n">to</span><span class="o">/</span><span class="n">openmicroscopy</span><span class="o">/</span><span class="n">etc</span><span class="o">/</span><span class="n">ice</span><span class="o">.</span><span class="n">config</span> <span class="n">export</span> <span class="n">OMERODIR</span><span class="o">=/</span><span class="n">path</span><span class="o">/</span><span class="n">to</span><span class="o">/</span><span class="n">OMERO</span><span class="o">.</span><span class="n">server</span><span class="o">-</span><span class="n">x</span><span class="o">.</span><span class="n">x</span><span class="o">.</span><span class="n">x</span><span class="o">-</span><span class="n">ice36</span><span class="o">-</span><span class="n">bxx</span> <span class="n">cd</span> <span class="n">components</span><span class="o">/</span><span class="n">tools</span><span class="o">/</span><span class="n">OmeroPy</span> <span class="n">pytest</span> <span class="n">test</span><span class="o">/</span><span class="n">integration</span><span class="o">/</span><span class="n">test_admin</span><span class="o">.</span><span class="n">py</span> <span class="c1"># OR for OmeroWeb tests:</span> <span class="n">cd</span> <span class="n">components</span><span class="o">/</span><span class="n">tools</span><span class="o">/</span><span class="n">OmeroWeb</span> <span class="n">pytest</span> <span class="n">test</span><span class="o">/</span><span class="n">integration</span><span class="o">/</span><span class="n">test_annotate</span><span class="o">.</span><span class="n">py</span> </pre></div> </div> <dl class="std option"> <dt class="sig sig-object std" id="cmdoption-pytest-k"> <span class="sig-name descname"><span class="pre">-k</span></span><span class="sig-prename descclassname"> <span class="pre"><string></span></span><a class="headerlink" href="#cmdoption-pytest-k" title="Permalink to this definition">ïƒ</a></dt> <dd><p>This option will run all integration tests containing the given string in their names. For example, to run all the tests under <code class="file docutils literal notranslate"><span class="pre">test/integration</span></code> with <cite>permissions</cite> in their names:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">pytest</span> <span class="n">test</span><span class="o">/</span><span class="n">integration</span> <span class="o">-</span><span class="n">k</span> <span class="n">permissions</span> </pre></div> </div> <p>This option can also be used to run a named test within a test module:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">pytest</span> <span class="n">test</span><span class="o">/</span><span class="n">integration</span><span class="o">/</span><span class="n">test_admin</span><span class="o">.</span><span class="n">py</span> <span class="o">-</span><span class="n">k</span> <span class="n">testGetGroup</span> </pre></div> </div> </dd></dl> <dl class="std option"> <dt class="sig sig-object std" id="cmdoption-pytest-m"> <span class="sig-name descname"><span class="pre">-m</span></span><span class="sig-prename descclassname"> <span class="pre"><marker></span></span><a class="headerlink" href="#cmdoption-pytest-m" title="Permalink to this definition">ïƒ</a></dt> <dd><p>This option will run integration tests depending on the markers they are decorated with. Available markers can be listed using the <a class="reference internal" href="#cmdoption-pytest-markers"><code class="xref std std-option docutils literal notranslate"><span class="pre">pytest</span> <span class="pre">--markers</span></code></a> option. For example, to run all integration tests excluding those decorated with the marker <cite>broken</cite>:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">pytest</span> <span class="n">test</span><span class="o">/</span><span class="n">integration</span> <span class="o">-</span><span class="n">m</span> <span class="s2">"not broken"</span> </pre></div> </div> </dd></dl> <dl class="std option"> <dt class="sig sig-object std" id="cmdoption-pytest-markers"> <span class="sig-name descname"><span class="pre">--markers</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-pytest-markers" title="Permalink to this definition">ïƒ</a></dt> <dd><p>This option lists available markers for decorating tests:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">pytest</span> <span class="o">--</span><span class="n">markers</span> </pre></div> </div> </dd></dl> <dl class="std option"> <dt class="sig sig-object std" id="cmdoption-pytest-s"> <span class="sig-name descname"><span class="pre">-s</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-pytest-s" title="Permalink to this definition">ïƒ</a></dt> <dd><p>This option allows the standard output to be shown on the console:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">pytest</span> <span class="n">test</span><span class="o">/</span><span class="n">integration</span><span class="o">/</span><span class="n">test_admin</span><span class="o">.</span><span class="n">py</span> <span class="o">-</span><span class="n">s</span> </pre></div> </div> </dd></dl> <dl class="std option"> <dt class="sig sig-object std" id="cmdoption-pytest-h"> <span id="cmdoption-pytest-help"></span><span class="sig-name descname"><span class="pre">-h</span></span><span class="sig-prename descclassname"></span><span class="sig-prename descclassname"><span class="pre">,</span> </span><span class="sig-name descname"><span class="pre">--help</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-pytest-h" title="Permalink to this definition">ïƒ</a></dt> <dd><p>This option displays the full list of available options:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">pytest</span> <span class="o">-</span><span class="n">h</span> </pre></div> </div> </dd></dl> <p>See <a class="reference external" href="https://docs.pytest.org/en/latest/how-to/usage.html">https://docs.pytest.org/en/latest/how-to/usage.html</a> for more help in running tests.</p> </section> </section> <section id="failing-tests"> <h3>Failing tests<a class="headerlink" href="#failing-tests" title="Permalink to this heading">ïƒ</a></h3> <p>The <code class="docutils literal notranslate"><span class="pre">test.with.fail</span></code> ant property is set to <code class="docutils literal notranslate"><span class="pre">false</span></code> by default, which prevents test failures from failing the build. However, it can instead be set to <code class="docutils literal notranslate"><span class="pre">true</span></code> to allow test failures to fail the build. For example:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">./</span><span class="n">build</span><span class="o">.</span><span class="n">py</span> <span class="o">-</span><span class="n">Dtest</span><span class="o">.</span><span class="k">with</span><span class="o">.</span><span class="n">fail</span><span class="o">=</span><span class="n">true</span> <span class="n">integration</span> </pre></div> </div> <p>Some components might provide individual targets for specific tests (e.g. OmeroJava provides the <code class="docutils literal notranslate"><span class="pre">broken</span></code> target for running broken tests). The <code class="file docutils literal notranslate"><span class="pre">build.xml</span></code> file is the reference in each component.</p> </section> </section> <section id="writing-tests"> <h2>Writing tests<a class="headerlink" href="#writing-tests" title="Permalink to this heading">ïƒ</a></h2> <section id="writing-java-tests"> <h3>Writing Java tests<a class="headerlink" href="#writing-java-tests" title="Permalink to this heading">ïƒ</a></h3> <p>For more information on writing tests in general see <a class="reference external" href="https://testng.org/">https://testng.org/</a>. For a test to be an “integration†test, place it in the “integration†TestNG group. If a test is temporarily broken, add it to the “broken†group:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nd">@Test</span><span class="p">(</span><span class="n">groups</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"integration"</span><span class="p">,</span> <span class="s2">"broken"</span><span class="p">}</span> <span class="n">public</span> <span class="n">void</span> <span class="n">testMyStuff</span><span class="p">()</span> <span class="p">{</span> <span class="p">}</span> </pre></div> </div> <p>Tests should be of the <strong>Acceptance Test</strong> form. The ticket number for which a test is being written should be added in the TestNG annotation:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nd">@Test</span><span class="p">(</span><span class="n">groups</span> <span class="o">=</span> <span class="s2">"ticket:60"</span><span class="p">)</span> </pre></div> </div> <p>This works at either the method level (see <a class="reference external" href="https://github.com/ome/omero-model/blob/v5.7.0/src/test/java/ome/model/utests/SetsAndLinksTest.java">SetsAndLinksTest.java</a>) or the class level (see <a class="reference external" href="https://github.com/ome/omero-server/blob/v5.7.0/src/test/java/ome/server/itests/query/UniqueResultTest.java">UniqueResultTest.java</a>).</p> <p>The tests under <a class="reference external" href="https://github.com/ome/openmicroscopy/tree/develop/components/tools/OmeroJava/test">https://github.com/ome/openmicroscopy/tree/develop/components/tools/OmeroJava/test</a> will be the starting point for most Java-client developers coming to OMERO. An example skeleton for an integration test looks similar to</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nd">@Test</span><span class="p">(</span><span class="n">groups</span> <span class="o">=</span> <span class="s2">"integration"</span><span class="p">)</span> <span class="n">public</span> <span class="k">class</span><span class="w"> </span><span class="nc">MyTest</span> <span class="p">{</span> <span class="n">omero</span><span class="o">.</span><span class="n">client</span> <span class="n">client</span><span class="p">;</span> <span class="nd">@BeforeClass</span> <span class="n">protected</span> <span class="n">void</span> <span class="n">setup</span><span class="p">()</span> <span class="n">throws</span> <span class="ne">Exception</span> <span class="p">{</span> <span class="n">client</span> <span class="o">=</span> <span class="n">new</span> <span class="n">omero</span><span class="o">.</span><span class="n">client</span><span class="p">();</span> <span class="n">client</span><span class="o">.</span><span class="n">createSession</span><span class="p">();</span> <span class="p">}</span> <span class="nd">@AfterClass</span> <span class="n">protected</span> <span class="n">void</span> <span class="n">tearDown</span><span class="p">()</span> <span class="n">throws</span> <span class="ne">Exception</span> <span class="p">{</span> <span class="n">client</span><span class="o">.</span><span class="n">closeSession</span><span class="p">();</span> <span class="p">}</span> <span class="nd">@Test</span> <span class="n">public</span> <span class="n">void</span> <span class="n">testSimple</span><span class="p">()</span> <span class="n">throws</span> <span class="ne">Exception</span> <span class="p">{</span> <span class="n">client</span><span class="o">.</span><span class="n">getSession</span><span class="p">()</span><span class="o">.</span><span class="n">getAdminService</span><span class="p">()</span><span class="o">.</span><span class="n">getEventContext</span><span class="p">();</span> <span class="p">}</span> <span class="p">}</span> </pre></div> </div> </section> <section id="writing-python-tests"> <span id="id2"></span><h3>Writing Python tests<a class="headerlink" href="#writing-python-tests" title="Permalink to this heading">ïƒ</a></h3> <p>To write and run Python tests you first need to install <cite>pytest</cite>:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">pip</span> <span class="n">install</span> <span class="n">pytest</span> </pre></div> </div> <p>For more information on writing tests in general see <a class="reference external" href="https://pytest.org/">https://pytest.org/</a>.</p> <p>Unit tests can be found in various repositories such as <a class="reference external" href="https://github.com/ome/omero-py/tree/v5.19.6/test/unit">omero-py</a>, <a class="reference external" href="https://github.com/ome/omero-web/tree/v5.28.0/test/unit">omero-web</a>, and <a class="reference external" href="https://github.com/ome/omero-dropbox/tree/v5.7.0/test/unit">omero-dropbox</a>.</p> <p>Integration tests which require OMERO.server to run are found in the <code class="docutils literal notranslate"><span class="pre">openmicroscopy</span></code> repository. See: <a class="reference external" href="https://github.com/ome/openmicroscopy/tree/develop/components/tools/OmeroPy/test">https://github.com/ome/openmicroscopy/tree/develop/components/tools/OmeroPy/test</a>, <a class="reference external" href="https://github.com/ome/openmicroscopy/tree/develop/components/tools/OmeroWeb/test">https://github.com/ome/openmicroscopy/tree/develop/components/tools/OmeroWeb/test</a> and <a class="reference external" href="https://github.com/ome/openmicroscopy/tree/develop/components/tools/OmeroFS/test">https://github.com/ome/openmicroscopy/tree/develop/components/tools/OmeroFS/test</a>.</p> <p>The file names must begin with <cite>test_</cite> for the tests to be found by <cite>pytest</cite>.</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span><span class="w"> </span><span class="nn">omero.clients</span> <span class="k">class</span><span class="w"> </span><span class="nc">TestExample</span><span class="p">(</span><span class="nb">object</span><span class="p">)</span> <span class="k">def</span><span class="w"> </span><span class="nf">setup_method</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">method</span><span class="p">):</span> <span class="n">client</span> <span class="o">=</span> <span class="n">new</span> <span class="n">omero</span><span class="o">.</span><span class="n">client</span><span class="p">()</span> <span class="n">client</span><span class="o">.</span><span class="n">createSession</span><span class="p">()</span> <span class="k">def</span><span class="w"> </span><span class="nf">teardown_method</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">method</span><span class="p">):</span> <span class="n">client</span><span class="o">.</span><span class="n">closeSession</span><span class="p">()</span> <span class="k">def</span><span class="w"> </span><span class="nf">testSimple</span><span class="p">():</span> <span class="n">ec</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">getSession</span><span class="p">()</span><span class="o">.</span><span class="n">getAdminService</span><span class="p">()</span><span class="o">.</span><span class="n">getEventContext</span><span class="p">()</span> <span class="k">assert</span> <span class="n">ec</span><span class="p">,</span> <span class="s2">"No EventContext!"</span> </pre></div> </div> <section id="marking-omeropy-tests"> <span id="marking-python-tests"></span><h4>Marking OmeroPy tests<a class="headerlink" href="#marking-omeropy-tests" title="Permalink to this heading">ïƒ</a></h4> <p>Methods, classes and functions can be decorated with <cite>pytest</cite> markers to allow for the selection of tests. <cite>pytest</cite> provides some predefined markers and markers can be simply defined as they are used. However, to centralize the use of custom markers they should be defined in <a class="reference external" href="https://github.com/ome/openmicroscopy/tree/develop/components/tools/pytest.ini">https://github.com/ome/openmicroscopy/tree/develop/components/tools/pytest.ini</a>.</p> <p>To view all available markers the <a class="reference internal" href="#cmdoption-pytest-markers"><code class="xref std std-option docutils literal notranslate"><span class="pre">pytest</span> <span class="pre">--markers</span></code></a> option can be used with <strong class="program">pytest</strong> or <strong class="program">py.test</strong> as detailed in <a class="reference internal" href="#running-python-tests-directly"><span class="std std-ref">Running tests directly</span></a>.</p> <p>There is one custom marker defined:</p> <dl class="glossary simple"> <dt id="term-broken"><cite>broken</cite><a class="headerlink" href="#term-broken" title="Permalink to this term">ïƒ</a></dt><dd><p>Used to mark broken tests. These are tests that fail consistently with no obvious quick fix. Broken tests are excluded from the main integration builds and instead are run in a separate daily build. <cite>broken</cite> markers should have a reason, an associated Trac ticket number or both. If there are multiple associated tickets then a comma-separated list should be used.</p> </dd> </dl> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span><span class="w"> </span><span class="nn">pytest</span> <span class="k">class</span><span class="w"> </span><span class="nc">TestExample2</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span> <span class="nd">@pytest</span><span class="o">.</span><span class="n">mark</span><span class="o">.</span><span class="n">broken</span><span class="p">(</span><span class="n">reason</span><span class="o">=</span><span class="s2">"Asserting false"</span><span class="p">,</span> <span class="n">ticket</span><span class="o">=</span><span class="s2">"12345,67890"</span><span class="p">)</span> <span class="k">def</span><span class="w"> </span><span class="nf">testBroken</span><span class="p">():</span> <span class="k">assert</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"Bound to fail"</span> </pre></div> </div> </section> <section id="using-the-python-test-library"> <h4>Using the Python test library<a class="headerlink" href="#using-the-python-test-library" title="Permalink to this heading">ïƒ</a></h4> <p>The <a class="reference external" href="https://github.com/ome/omero-py/blob/master/src/omero/testlib/__init__.py">OMERO Python test library</a> defines an abstract <code class="docutils literal notranslate"><span class="pre">ITest</span></code> class that implements the connection set up as well as many methods shared amongst all Python integration tests.</p> <p>Each concrete instance of the <code class="docutils literal notranslate"><span class="pre">ITest</span></code> will initiate a connection to the server specified by the <span class="target" id="index-7"></span><code class="xref std std-envvar docutils literal notranslate"><span class="pre">ICE_CONFIG</span></code> environment variable at the <code class="docutils literal notranslate"><span class="pre">setup_class()</span></code> level. The following objects are created by <code class="docutils literal notranslate"><span class="pre">ITest.setup_class()</span></code> and shared by all test methods of this class:</p> <ul class="simple"> <li><p><code class="docutils literal notranslate"><span class="pre">self.root</span></code> is a client for the root user</p></li> <li><p><code class="docutils literal notranslate"><span class="pre">self.group</span></code> is a new group which permissions are set to <code class="docutils literal notranslate"><span class="pre">ITest.DEFAULT_PERMS</span></code> by default. Overriding <code class="docutils literal notranslate"><span class="pre">DEFAULTS_PERMS</span></code> in a subclass of <code class="docutils literal notranslate"><span class="pre">ITest</span></code> means the group will be created with the new permissions.</p></li> <li><p><code class="docutils literal notranslate"><span class="pre">self.user</span></code> is a new user and member of <code class="docutils literal notranslate"><span class="pre">self.group</span></code></p></li> <li><p><code class="docutils literal notranslate"><span class="pre">self.client</span></code> is a client for the <code class="docutils literal notranslate"><span class="pre">self.user</span></code> created at class setup.</p></li> </ul> <p>Additionally, for the <code class="docutils literal notranslate"><span class="pre">self.client</span></code> object, different shortcuts are available:</p> <ul class="simple"> <li><p><code class="docutils literal notranslate"><span class="pre">self.sf</span></code> is the non-root client session</p></li> <li><p><code class="docutils literal notranslate"><span class="pre">self.update</span></code> is the update service for the non-root client session</p></li> <li><p><code class="docutils literal notranslate"><span class="pre">self.query</span></code> is the query service for the non-root client session</p></li> <li><p><code class="docutils literal notranslate"><span class="pre">self.ctx</span></code> is the event context for the non-root client session. Note this corresponds to the context at creation time and should be refreshed if the context is modified.</p></li> </ul> <p>The example below inherits the <code class="docutils literal notranslate"><span class="pre">ITest</span></code> class and would create a read-write group by default</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span><span class="w"> </span><span class="nn">omero.testlib</span><span class="w"> </span><span class="kn">import</span> <span class="n">ITest</span> <span class="k">class</span><span class="w"> </span><span class="nc">TestExample</span><span class="p">(</span><span class="n">ITest</span><span class="p">):</span> <span class="n">DEFAULT_PERMS</span> <span class="o">=</span> <span class="s1">'rwrw--'</span> <span class="c1"># Override default permissions</span> <span class="k">def</span><span class="w"> </span><span class="nf">test1</span><span class="p">():</span> <span class="n">doAction</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sf</span><span class="p">)</span> </pre></div> </div> <p>New user and groups can be instantiated by individual tests using the <code class="docutils literal notranslate"><span class="pre">ITest.new_user()</span></code> and <code class="docutils literal notranslate"><span class="pre">ITest.new_group()</span></code> methods:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span><span class="w"> </span><span class="nf">testNewGroupOwner</span><span class="p">():</span> <span class="n">new_group</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">new_group</span><span class="p">(</span><span class="n">perms</span><span class="o">=</span><span class="s1">'rwa---'</span><span class="p">)</span> <span class="n">new_owner</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">new_use</span><span class="p">(</span><span class="n">group</span><span class="o">=</span><span class="n">new_group</span><span class="p">,</span> <span class="n">owner</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> <span class="k">assert</span> <span class="n">new_owner</span><span class="o">.</span><span class="n">id</span><span class="o">.</span><span class="n">val</span><span class="p">,</span> <span class="s2">"No EventContext!"</span> </pre></div> </div> <p>New clients can be instantiated by individual tests using the <code class="docutils literal notranslate"><span class="pre">ITest.new_client()</span></code> or <code class="docutils literal notranslate"><span class="pre">ITest.new_client_and_user()</span></code> methods:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span><span class="w"> </span><span class="nf">testNewClient</span><span class="p">():</span> <span class="n">new_client</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">new_user_and_client</span><span class="p">()</span> <span class="n">ec</span> <span class="o">=</span> <span class="n">new_client</span><span class="o">.</span><span class="n">getSession</span><span class="p">()</span><span class="o">.</span><span class="n">getAdminService</span><span class="p">()</span><span class="o">.</span><span class="n">getEventContext</span><span class="p">()</span> <span class="k">assert</span> <span class="n">ec</span><span class="p">,</span> <span class="s2">"No EventContext!"</span> </pre></div> </div> <p>Images can be imported using the <code class="docutils literal notranslate"><span class="pre">ITest.import_fake_file()</span></code> method:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span><span class="w"> </span><span class="nf">testFileset</span><span class="p">():</span> <span class="c1"># 2 images sharing a fileset</span> <span class="n">images</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">import_fake_file</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span> <span class="k">assert</span> <span class="nb">len</span><span class="p">(</span><span class="n">images</span><span class="p">)</span> <span class="o">==</span> <span class="mi">2</span> </pre></div> </div> </section> <section id="writing-omero-web-tests"> <h4>Writing OMERO.web tests<a class="headerlink" href="#writing-omero-web-tests" title="Permalink to this heading">ïƒ</a></h4> <p>For OMERO.web integration tests, the <a class="reference external" href="https://github.com/ome/omero-web/blob/master/omeroweb/testlib/__init__.py">OMERO.web test library</a> defines an abstract <code class="docutils literal notranslate"><span class="pre">IWebTest</span></code> class that inherits from <code class="docutils literal notranslate"><span class="pre">ITest</span></code> and also implements Django clients at the class setup using the <a class="reference external" href="https://docs.djangoproject.com/en/4.2/topics/testing/tools">Django testing tools</a>.</p> <p>On top of the elements created by <code class="docutils literal notranslate"><span class="pre">ITest.setup_class()</span></code>, the <code class="docutils literal notranslate"><span class="pre">IWebTest</span></code> class creates:</p> <ul class="simple"> <li><p><code class="docutils literal notranslate"><span class="pre">self.django_root_client</span></code> is a Django test client for the root user</p></li> <li><p><code class="docutils literal notranslate"><span class="pre">self.django_client</span></code> is a client for the new user created at the class setup.</p></li> </ul> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span><span class="w"> </span><span class="nn">omeroweb.testlib</span><span class="w"> </span><span class="kn">import</span> <span class="n">IWebTest</span> <span class="k">class</span><span class="w"> </span><span class="nc">TestExample</span><span class="p">(</span><span class="n">IWebTest</span><span class="p">):</span> <span class="k">def</span><span class="w"> </span><span class="nf">testSimple</span><span class="p">():</span> <span class="bp">self</span><span class="o">.</span><span class="n">django_client</span><span class="o">.</span><span class="n">post</span><span class="p">(</span><span class="s1">'/login/'</span><span class="p">,</span> <span class="p">{</span><span class="s1">'username'</span><span class="p">:</span> <span class="s1">'john'</span><span class="p">})</span> </pre></div> </div> <p>New Django test clients can be instantiated by individual tests using the <code class="docutils literal notranslate"><span class="pre">IWebTest.new_django_client()</span></code> method:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span><span class="w"> </span><span class="nf">testNewDjangoClient</span><span class="p">():</span> <span class="n">new_user</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">new_user</span><span class="p">()</span> <span class="n">omeName</span> <span class="o">=</span> <span class="n">new_user</span><span class="o">.</span><span class="n">omeName</span><span class="o">.</span><span class="n">val</span> <span class="n">new_django_client</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">new_django_client</span><span class="p">(</span><span class="n">omeName</span><span class="p">,</span> <span class="n">omeName</span><span class="p">)</span> </pre></div> </div> <div class="admonition seealso"> <p class="admonition-title">See also</p> <dl class="simple"> <dt><a class="reference external" href="https://github.com/ome/openmicroscopy/blob/develop/components/tools/OmeroWeb/test/integration/test_simple.py">test_simple.py</a></dt><dd><p>Example test class using the OMERO.web test library methods</p> </dd> </dl> </div> </section> </section> </section> </section> </div> </div> <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer"> <a href="GettingStarted.html" class="btn btn-neutral float-left" title="Working with OMERO" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a> <a href="Python.html" class="btn btn-neutral float-right" title="OMERO Python language bindings" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a> </div> <hr/> <div role="contentinfo"> <p>© Copyright 2000-2025, The Open Microscopy Environment.</p> </div> Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. </footer> </div> </div> </section> </div> <script> jQuery(function () { SphinxRtdTheme.Navigation.enable(true); }); </script> </body> </html>