Hello! Presentation and module wrappers for unit testing.

Hello!

My name is Jorge and I’have been using ansible and programming for at least two years now.

I have developed an action_plugin + module for handling GnuPG keys and encryption and during
the development I have found hard to test the module as it has over 1000 lines of code so I had to
build some unit tests to help me test each layer of the module independently.

For doing that and testing the ansible module layer I’ve built a couple of module runners that can
be called from inside a unittest, one grabs stdout and runs the module parsing the json output,
the problem with this one is that you can’t use pdb as stdout is redirected.

The other one works patching the AnsibleModule object exit_json and fail_json methods so it allows
you to tinker with pdb but it doesn’t catch if the module is leaking to stdout.

The classes are found in this module.

https://github.com/llou/gpg_ansible/blob/master/test/util.py

And the functions are called run_module_internally and run_module_debug. Hope you find them useful.

Keep up with the good job!

Jorge Monforte

Thanks for sharing!