These need to be ignored AFAIU, same reason why pytest fails. Example from network role:
Yes - or sys.path and something more. Here is what I did for the network role:
https://github.com/linux-system-roles/network/blob/master/tests/unit/test_nm_provider.py#L20The challenge is that Ansible accesses the module in a different namespace than what is actually on the system.
I guess for the storage role it would be something like this:
import os
import sys
TESTS_BASEDIR = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(1, os.path.join(TESTS_BASEDIR, "../..", "library"))
sys.path.insert(1, os.path.join(TESTS_BASEDIR, "../..", "module_utils"))
try:
from unittest import mock
except ImportError: # py2
import mock
sys.modules["ansible"] = mock.Mock()
sys.modules["ansible.module_utils.basic"] = mock.Mock()
sys.modules["ansible.module_utils"] = mock.Mock()
sys.modules["ansible.module_utils.size"] = __import__("size")
Kind regards
Till