I'm starting to migrate my module project into a collection and I'm running into issues with missing test utility functions like:
tests/unit/plugins/lookup/test_pfsense.py:10: in <module>
from units.compat.mock import patch
E ImportError: No module named units.compat.mock
tests/unit/plugins/modules/test_pfsense_aggregate.py:13: in <module>
from units.modules.utils import set_module_args
E ImportError: No module named units.modules.utils
From poking around in the various collection repositories it appears that many collections are now carrying local copies of these. Is this really the plan here? It seems - not ideal.
I'm starting to migrate my module project into a collection and I'm
running into issues with missing test utility functions like:
tests/unit/plugins/lookup/test_pfsense.py:10: in <module>
from units.compat.mock import patch
E ImportError: No module named units.compat.mock
tests/unit/plugins/modules/test_pfsense_aggregate.py:13: in <module>
from units.modules.utils import set_module_args
E ImportError: No module named units.modules.utils
From poking around in the various collection repositories it appears
that many collections are now carrying local copies of these. Is
this really the plan here? It seems - not ideal.
Thanks, I've used that in my project. I wonder if a tests dependency
tag is in order for galaxy.yml?
good question. From how I understood it, adding things to galaxy.yml is
complicated since it is converted to MANIFEST.json during collection
build, and that might be strictly validated by Galaxy / AH itself.
In any case, there already exists a "proposal" for a test dependency
file: tests/requirements.yml
This file was created by the collection migration tool used when moving
content from ansible/ansible into collection repositories. It is not
used by ansible-test at the moment, and I have no idea whether there
are actual plans of supporting it eventually.
I had a look to this interesting internal test collection, yet I cannot make it work, my ansible-test units command keeps complaining that the following path cannot be found:
from ansible_collections.community.internal_test_tools.tests.unit.compat import unittest
from ansible_collections.community.internal_test_tools.tests.unit.compat.mock import Mock, patch
I had a look to this interesting internal test collection, yet I
cannot make it work, my ansible-test units command keeps complaining
that the following path cannot be found:
from
ansible_collections.community.internal_test_tools.tests.unit.compat
import unittest from
ansible_collections.community.internal_test_tools.tests.unit.compat.mock
import Mock, patch
What is the procedure to follow to set it up ?
did you install the collection in the same path structure that the
collection you are running ansible-test on is in?