mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-25 20:01:25 -07:00
[stable-9] Unit tests: make set_module_args() a context manager, and remove copies of it in some tests (#9840)
Unit tests: make set_module_args() a context manager, and remove copies of it in some tests (#9838)
Make set_module_args() a context manager, and remove copies of set_module_args().
Prepares for Data Tagging.
(cherry picked from commit a1781d09dd
)
This commit is contained in:
parent
9a6bd80613
commit
013fb9c006
80 changed files with 3745 additions and 3977 deletions
|
@ -54,16 +54,16 @@ def test_zone_create(mocked_zone_create, capfd):
|
|||
"""
|
||||
test zone creation
|
||||
"""
|
||||
set_module_args(
|
||||
with set_module_args(
|
||||
{
|
||||
"name": "z1",
|
||||
"state": "installed",
|
||||
"path": "/zones/z1",
|
||||
"_ansible_check_mode": False,
|
||||
}
|
||||
)
|
||||
with pytest.raises(SystemExit):
|
||||
solaris_zone.main()
|
||||
):
|
||||
with pytest.raises(SystemExit):
|
||||
solaris_zone.main()
|
||||
|
||||
out, err = capfd.readouterr()
|
||||
results = json.loads(out)
|
||||
|
@ -75,16 +75,16 @@ def test_zone_delete(mocked_zone_delete, capfd):
|
|||
"""
|
||||
test zone deletion
|
||||
"""
|
||||
set_module_args(
|
||||
with set_module_args(
|
||||
{
|
||||
"name": "z1",
|
||||
"state": "absent",
|
||||
"path": "/zones/z1",
|
||||
"_ansible_check_mode": False,
|
||||
}
|
||||
)
|
||||
with pytest.raises(SystemExit):
|
||||
solaris_zone.main()
|
||||
):
|
||||
with pytest.raises(SystemExit):
|
||||
solaris_zone.main()
|
||||
|
||||
out, err = capfd.readouterr()
|
||||
results = json.loads(out)
|
||||
|
@ -100,16 +100,16 @@ def test_zone_create_invalid_names(mocked_zone_create, capfd):
|
|||
# 2. Zone name > 64 characters.
|
||||
# 3. Zone name beginning with non-alphanumeric character.
|
||||
for invalid_name in ('foo!bar', 'z' * 65, '_zone'):
|
||||
set_module_args(
|
||||
with set_module_args(
|
||||
{
|
||||
"name": invalid_name,
|
||||
"state": "installed",
|
||||
"path": "/zones/" + invalid_name,
|
||||
"_ansible_check_mode": False,
|
||||
}
|
||||
)
|
||||
with pytest.raises(SystemExit):
|
||||
solaris_zone.main()
|
||||
):
|
||||
with pytest.raises(SystemExit):
|
||||
solaris_zone.main()
|
||||
|
||||
out, err = capfd.readouterr()
|
||||
results = json.loads(out)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue