Skip to content

Commit

Permalink
Use pytest-ansible instead of pytest-ansible-units (#1553)
Browse files Browse the repository at this point in the history
Use pytest-ansible instead of pytest-ansible-units

SUMMARY


pytest-ansible-units is archived and replaced by pytest-ansible
Usage of 'ansible_' variable names has been modified due to this issue
ISSUE TYPE


Bugfix Pull Request
Docs Pull Request
Feature Pull Request
New Module Pull Request

COMPONENT NAME

ADDITIONAL INFORMATION

Reviewed-by: Mark Chappell
  • Loading branch information
GomathiselviS authored May 17, 2023
1 parent b9d5b48 commit 1692e28
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
3 changes: 3 additions & 0 deletions changelogs/fragments/add-pytest-ansible.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
trivial:
- Replace pytest-ansible-units with pytest-ansible for testing unit tests (https://github.com/ansible-collections/amazon.aws/pull/1553).
2 changes: 1 addition & 1 deletion test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pytest
pytest-forked
pytest-mock
pytest-xdist
pytest-ansible-units ; python_version > '3.8'
pytest-ansible

# Needed for ansible.utils.ipaddr in tests
netaddr
Expand Down
10 changes: 5 additions & 5 deletions tests/unit/plugins/modules/test_lambda_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def raise_lambdalayer_exception(e=None, m=None):


@pytest.mark.parametrize(
"params,api_result,calls,ansible_result",
"params,api_result,calls,_ansible_result",
[
({"name": "testlayer", "version": 4}, [], [], {"changed": False, "layer_versions": []}),
(
Expand Down Expand Up @@ -121,13 +121,13 @@ def raise_lambdalayer_exception(e=None, m=None):
],
)
@patch(mod_list_layer)
def test_delete_layer(m_list_layer, params, api_result, calls, ansible_result):
def test_delete_layer(m_list_layer, params, api_result, calls, _ansible_result):
lambda_client = MagicMock()
lambda_client.delete_layer_version.return_value = None

m_list_layer.return_value = api_result
result = lambda_layer.delete_layer_version(lambda_client, params)
assert result == ansible_result
assert result == _ansible_result

m_list_layer.assert_called_once_with(lambda_client, params.get("name"))

Expand Down Expand Up @@ -160,7 +160,7 @@ def test_delete_layer_check_mode(m_list_layer):
]
params = {"name": "testlayer", "version": -1}
result = lambda_layer.delete_layer_version(lambda_client, params, check_mode=True)
ansible_result = {
_ansible_result = {
"changed": True,
"layer_versions": [
{
Expand All @@ -179,7 +179,7 @@ def test_delete_layer_check_mode(m_list_layer):
},
],
}
assert result == ansible_result
assert result == _ansible_result

m_list_layer.assert_called_once_with(lambda_client, params.get("name"))
lambda_client.delete_layer_version.assert_not_called()
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ deps =
ansible2.12: ansible-core>2.12,<2.13
ansible2.13: ansible-core>2.13,<2.14
!ansible2.12-!ansible2.13: ansible-core
pytest-ansible-units
pytest-ansible
-rtest-requirements.txt
with_constraints: -rtests/unit/constraints.txt
commands = pytest --cov-report html --cov plugins/callback --cov plugins/inventory --cov plugins/lookup --cov plugins/module_utils --cov plugins/modules --cov plugins/plugin_utils plugins {posargs:tests/}
Expand Down

0 comments on commit 1692e28

Please sign in to comment.