Closed flachica closed 10 months ago
docker compose run --rm odoo odoo test ...
uses pytest under the hood and doesn't know what an Odoo module is. Using the tests using the Odoo framework Odoo does the mapping. I assume that the module is from an additional repo. In that case the modules are symlinked inside the container to /tmp/addons/...
which means it would be docker compose run --rm odoo odoo test /tmp/addons/pos_default_partner
. If you are also interrested in the coverage: docker compose run --rm odoo odoo test /tmp/addons/pos_default_partner --cov /tmp/addons/pos_default_partner
. If you need additional filtering you can leverage the -k
of pytest.
Thank you very much for responding so quickly @fkantelberg.
I have made some progress on this. To point out that the module I am trying to test is "base" which is included in standard Odoo. To rule out any problems with my local configuration
I have cloned the project into an empty directory and then run:
./setup.sh
docker compose build
docker-compose run --rm odoo odoo init
docker-compose run --rm odoo odoo update
docker-compose up
Following these steps Odoo starts correctly
When launching the test the system does not find it
docker-compose run --rm odoo odoo odoo test /tmp/web
reating dob_odoo_run ... done
2023-11-20 10:26:34 INFO doblib.utils: Loading configuration file
2023-11-20 10:26:34 INFO doblib.utils: * odoo.local.yaml
2023-11-20 10:26:34 INFO doblib.utils: * odoo.project.yaml
2023-11-20 10:26:34 INFO doblib.utils: * odoo.default.yaml
2023-11-20 10:26:34 INFO doblib.utils: * odoo.yaml
2023-11-20 10:26:34 INFO doblib.utils: * defuse.yaml
2023-11-20 10:26:34 INFO doblib.utils: * anonymize.yaml
2023-11-20 10:26:34 WARNING doblib.utils: * odoo.versions.yaml
2023-11-20 10:26:34 INFO doblib.utils: Linking Odoo modules
2023-11-20 10:26:34,945 1 WARNING ? py.warnings: /srv/odoo/odoo/parts/odoo/odoo/tools/config.py:565: DeprecationWarning: The longpolling-port is a deprecated alias to the gevent-port option, please use the latter.
File "/usr/local/bin/dob", line 8, in <module>
sys.exit(main())
File "/usr/local/lib/python3.8/site-packages/doblib/__main__.py", line 136, in main
sys.exit(CIEnvironment(args.cfg).test(left))
File "/usr/local/lib/python3.8/site-packages/doblib/ci.py", line 205, in test
config.parse_config(["-c", base.ODOO_CONFIG])
File "/srv/odoo/odoo/parts/odoo/odoo/tools/config.py", line 378, in parse_config
self._warn_deprecated_options()
File "/srv/odoo/odoo/parts/odoo/odoo/tools/config.py", line 565, in _warn_deprecated_options
warnings.warn(
2023-11-20 10:26:34,945 1 INFO ? odoo: Odoo version 16.0
2023-11-20 10:26:34,945 1 INFO ? odoo: Using configuration file at /srv/odoo/odoo/etc/odoo.cfg
2023-11-20 10:26:34,945 1 INFO ? odoo: addons paths: ['/srv/odoo/odoo/parts/odoo/odoo/addons', '/srv/odoo/filestore/addons/16.0', '/tmp/addons', '/srv/odoo/odoo/src/addons']
2023-11-20 10:26:34,945 1 INFO ? odoo: database: odoo@db:5432
============================================================================ test session starts ============================================================================
platform linux -- Python 3.8.18, pytest-7.4.3, pluggy-1.3.0
rootdir: /srv/odoo/odoo
plugins: odoo-1.0.0, cov-4.1.0
collected 0 items
=========================================================================== no tests ran in 0.01s ===========================================================================
ERROR: file or directory not found: base
ERROR: 4
It strikes me that when I enter the odoo container with:
docker compose run odoo sleep 10000000
The /tmp/addons directory is empty
If you use run
you create a new container. The creation and linking of /tmp/addons
[1] is done in various processes by the dob-lib wrapper. (basically when it's needed) If you run and bash etc. you get into a container without the linking because the wrapper never runs. If you enter a container with exec
of a running Odoo or a shell you see the folder. We would need to use the entrypoint if this is necessary but there was no requirement until now. If you need the linked modules inside of a container with bash
The command is:
docker-compose run --rm odoo odoo test /tmp/addons/web
The first odoo
is the Odoo service defined in the docker-compose.yaml. The 2nd odoo
is a small script (see the bin
folder) which switches the working dir and passed the arguments to dob-lib. --rm
to remove the container after usage.
If I need a bash with the modules linked I go into the bash with run. Start odoo shell
shortly and close it.
[1] linking source
Great response. You solved my problem, as well as, clarified many points of the project lifecycle. I am very grateful.
I have Odoo working with this tool perfectly. If I run the tests with this command it works correctly:
But when run the tests with:
However, when I read the log I get the following message: