1
0
mirror of https://github.com/ansible-collections/community.general.git synced 2025-07-29 07:41:16 +03:00

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.
This commit is contained in:
Felix Fontein
2025-03-07 07:21:03 +01:00
committed by GitHub
parent 402f725424
commit a1781d09dd
84 changed files with 4043 additions and 4302 deletions

View File

@ -105,15 +105,14 @@ class TestKeycloakRealmRole(ModuleTestCase):
}
]
set_module_args(module_args)
# Run the module
with mock_good_connection():
with patch_keycloak_api(get_realm_info_by_id=return_value) \
as (mock_get_realm_info_by_id):
with self.assertRaises(AnsibleExitJson) as exec_info:
self.module.main()
with set_module_args(module_args):
with mock_good_connection():
with patch_keycloak_api(get_realm_info_by_id=return_value) \
as (mock_get_realm_info_by_id):
with self.assertRaises(AnsibleExitJson) as exec_info:
self.module.main()
self.assertEqual(len(mock_get_realm_info_by_id.mock_calls), 1)