Debugging the Redfish API is relatively easy since JSON is at least partially human-readable (programmer-readable maybe? ;).
Inspect the Redfish API responses using curl is relatively simple. We start
by running this:
| --- | |
| - hosts: localhost | |
| gather_facts: false | |
| tasks: | |
| - name: Test | |
| shell: echo {{ item }} | |
| with_flattened: | |
| - [ a, b, c ] | |
| - [ d, e ] |
| server { | |
| {% for location in nginx_extra_basic_location_options %} | |
| {{ location }}; | |
| {% endfor %} | |
| } |
| # Installation | |
| python3 -m venv venv | |
| . venv/bin/activate | |
| pip install ansible-argspec-gen[base] | |
| # Dry run with diagnostics | |
| ansible-argspec-gen --diff --dry-run sample.py | |
| echo $? # Will report back 1 | |
| # Perform changes |
| $ ansible-test units --python 3.8 tests/unit/modules/test_asset.py | |
| WARNING: PyYAML will be slow due to installation without libyaml support for interpreter: /home/tadej/xlab/sensu/venvt/bin/python | |
| Unit test with Python 3.8 | |
| ================================================= test session starts ================================================= | |
| platform linux -- Python 3.8.3, pytest-6.0.1, py-1.9.0, pluggy-0.13.1 | |
| rootdir: /home/tadej/xlab/sensu/ansible_collections/sensu/sensu_go/tests/unit/modules, configfile: ../../../../../../venvt/lib64/python3.8/site-packages/ansible_test/_data/pytest.ini | |
| plugins: xdist-1.34.0, forked-1.3.0, mock-3.2.0 | |
| gw0 [0] / gw1 [0] / gw2 [0] / gw3 [0] / gw4 [0] / gw5 [0] / gw6 [0] / gw7 [0] | |
| ======================================================= ERRORS ======================================================== |
| # -*- coding: utf-8 -*- | |
| # (c) 2020, Ansible Project | |
| # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) | |
| from __future__ import absolute_import, division, print_function | |
| __metaclass__ = type | |
| import pytest | |
| #!/bin/bash | |
| mkdir vmware && cd vmware | |
| mkdir -p collections/ansible_collections/community | |
| git clone \ | |
| --depth=1 \ | |
| https://github.com/ansible-collections/vmware.git \ | |
| collections/ansible_collections/community/vmware |
| #!/bin/bash | |
| rm -rf x.git y | |
| git init --bare x.git | |
| git clone x.git y | |
| cd y | |
| echo bla > bla.txt |
| --- | |
| - name: Test | |
| hosts: localhost | |
| gather_facts: false | |
| tasks: | |
| - name: Dummy data | |
| shell: echo -e "1 a\n1 b\n1 c\n" | |
| register: result |
| $ ansible-test units tests/unit/test_x.py | |
| ... | |
| ========================================== FAILURES =========================================== | |
| ________________________________________ test_my_stuff ________________________________________ | |
| [gw0] linux -- Python 3.7.6 /tmp/python-8s1dwmns-ansible/python | |
| def test_my_stuff(): | |
| > assert dict(a=3) == dict(b=2) | |
| E AssertionError | |
| tests/unit/test_x.py:2: AssertionError |