fix: fix modules validation and tests #62
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Most of modules are broken for various reasons:
This is a first pass on the
secret
modules to define boilerplate code for unit testing and fix itGoals
Write units test with monkey patching the different API calls to validate arguments and logic
Refactor the
plugins/module_utils/scaleway.py
=> simplify and build the scaleway client directly from the Python SDK Client instantiation logic (get rid oif arguments overlapping issues)Test, run
ansible-test integration --start-at scaleway_secret --requirements
SCW_PROFILE=owner SCW_DEFAULT_REGION=fr-par SCW_CONFIG_PATH="/Users/gnoale/git/scaleway/scaleway-cli/my_cfg.yml" ansible-playbook playbook.yaml
there are a few caveat
ansible-test units
uses pytest and a special modulepytest-xdist
For Macos user you need this environment variable
export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES
and
pip install pytest-xdist
Using a local virtual env as always !
ansible-test units --python-interpreter .venv/bin/python
Next
...
Caveat
ansible-test sanity
ignore completely the python path argument when it fires, so this explain in part all theAnd the typing trick is to wrap "Client" type in quotes in func signatures
Otherwise, it try importing modules as relative and return these kind of validation errors
"Exception attempting to import module for argument_spec introspection, 'name 'Client' is not defined'"