Can't find bin/test to utilize senaite.api

In order to use Senaite LIMS API, the Doctests instructions indicate that the bin/test test_textual_doctests -t API command must be run. The bin directory created for Senaite LIMS contains: backup, buildout, instance, plonectl, repozo, restore, snapshotbackup, snapshotrestore, and zopepy. Is this ‘bin’ directory where I should be looking to find ‘test’. Any insight would be appreciated.

Thank you for your time

You need to add the “test” part in the the buildout file (buildout.cfg, probably) and run bin/buildout afterwards (see
Unit testing — Plone Documentation v5.2).

parts =
    ...
    test

[test]
recipe = zc.recipe.testrunner
defaults = ['--auto-color', '--auto-progress']
eggs =
    senaite.core [test]

Thank you! I am able to find ‘test’ now.

I have found two versions of the test command to run:
bin/test test_textual_doctests -t API
bin/test test_doctests -t API

The first yields:
Total: 0 tests, 0 failures, 0 errors in 0.000 seconds.

The second yields:
Test-module import failures:

Module: senaite.api.tests.test_doctests

Traceback (most recent call last):
File “/home/senaite/buildout-cache/eggs/senaite.api-1.2.0-py2.7.egg/senaite/api/tests/test_doctests.py”, line 7, in
import unittest2 as unittest
ImportError: No module named unittest2

Test-modules with import problems:
senaite.api.tests.test_doctests
Total: 0 tests, 0 failures, 0 errors in 0.000 seconds.

I’ve tried to pip install unittest2, but that did not resolve the error.

Do you have any insight into this error?

pip install won’t affect what packages are available for Plone. Those will need to be added to your buildout.cfg file.

I haven’t dug around with the test suite itself, but my guess is what you are looking for is adding unittest2 to your buildout eggs list in the [buildout] section.

eggs =
    Plone
    Pillow
    Products.PloneHotfix20200121
    senaite.core
    senaite.lims
    senaite.impress
    senaite.jsonapi
    unittest2 #Add this line

It looks like the newest version is compatible with python2.7, but if they release a python3+ version in the future, then you might need to pin the version down at the bottom under the [versions] section.

[versions]
unittest2 = 1.1.0 #This line may be necessary in the future
isort = 4.0.0
Pillow = 5.1.0
cssselect2 = 0.2.2
soupsieve = 1.9.5
importlib-resources = 3.3.1
buildout.sanitycheck = 1.0.2
collective.recipe.backup = 4.1.0
plone.recipe.unifiedinstaller = 5.2b1
Products.PloneHotfix20200121 = 1.1

Thank you for your response. I used this method already and received this error:

Test-module import failures:

Module: senaite.api.tests.test_doctests

Traceback (most recent call last):
File “/home/senaite/buildout-cache/eggs/senaite.api-1.2.0-py2.7.egg/senaite/api/tests/test_doctests.py”, line 11, in
from .base import SimpleTestCase
File “/home/senaite/buildout-cache/eggs/senaite.api-1.2.0-py2.7.egg/senaite/api/tests/base.py”, line 5, in
from plone.testing import z2
ImportError: No module named testing

Test-modules with import problems:
senaite.api.tests.test_doctests
Total: 0 tests, 0 failures, 0 errors in 0.000 seconds.

Adding ‘testing’ to the eggs list in the [buildout] section does not resolve this error.

I had a struggle to get this running also, but the answer above solved the issue for me.

If you didn’t solve this, will you please post your entire buildout?

Here is the entire buildout excluding any lines associated with comments:

[buildout]
index = https://pypi.python.org/simple
extends =
base.cfg
versions.cfg

find-links +=
http://dist.plone.org/release/4.3.19

effective-user = senaite
buildout-user = senaite
need-sudo = no

eggs =
Plone
Pillow
senaite.lims
simplejson
senaite.jsonapi
senaite.api
unittest2

var-dir=${buildout:directory}/var

backups-dir=${buildout:var-dir}

user=admin:admin

deprecation-warnings = off

verbose-security = off

parts =
instance
repozo
backup
zopepy
unifiedinstaller
test

[test]
recipe = zc.recipe.testrunner
defaults = [’–auto-color’, ‘–auto-progress’]
eggs =
${instance:eggs}

[instance]
<= instance_base
recipe = plone.recipe.zope2instance
http-address = 8080

[versions]
zc.buildout =
setuptools =
unittest2 = 1.1.0
Pillow = 5.1.0
cssselect2 = 0.2.2
soupsieve = 1.9.5
Werkzeug = 1.0.1
buildout.sanitycheck = 1.0.2
collective.recipe.backup = 4.0
plone.recipe.unifiedinstaller = 4.3.2

Thank you @campbell for taking an interest in my issue.

Hm. Well, now I need help in turn! in order to try and mimic this issue I started from scratch, followed installation instructions from senaite.com, I had some issues:

  • I had to use 4.3.19, because 4.3.20 (latest) is not available on plone.org (it’s just… not).
  • Buildout refused to download senaite.lims-135 for me; no matter if I updated the index value, updated to new pypi index url and findlinks, set PYTHONHTTPSVERIFY… it won’t do it.
  • That’s fine, I manually installed these and their dependencies as develop eggs.
  • Alright, senaite.lims requires Plone 4.3.20. Edit setup.py to reset the pin to 4.3.19…

When the required cssselect2 (0.3.0) told me that it no longer supports Python2, I thought I’d take a break.

How did you do it?

During my dev work, I’ve just been using buildout.coredev from the senaite github.

It installs Plone 5.2.4, and this is the case that I have locally, where adding the [test] part as above works to allow me to test senaite eggs.

Remove senaite.api, is an obsolete package (its repos is archived, actually). System will install and work just fine without. Yes, you have to stick to Plone 4.3.20 if you install senaite.lims 1.3.5 (this LTS version was released two days ago), look at the dependencies: senaite.lims/setup.py at 1.3.5 · senaite/senaite.lims · GitHub

I received a number of command prompts after executing bin/test test_textual_doctests -t API, excerpting the last few sentences:
“Ran 8 tests with 0 failures, 0 errors, 0 skipped in 21.372 seconds.
Tearing down left over layers:
Tear down senaite.core.tests.layers.SENAITE:BaseTesting in 0.000 seconds.
Tear down senaite.core.tests.layers.BaseLayer in 0.005 seconds.
Tear down plone.app.testing.layers.PloneFixture in 0.032 seconds.
Tear down plone.testing.zope.Startup in 0.005 seconds.
Tear down plone.testing.zca.LayerCleanup in 0.002 seconds.”

There is no procedure as described in the test documentation:

"API
The purpose of this API is to help coders to follow the DRY principle (Don’t Repeat Yourself). It also ensures that the most effective and efficient method is used to achieve a task.
Import it first:

from bika.lims import api "