mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-23 19:01:26 -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
|
@ -235,20 +235,19 @@ class TestKeycloakAuthentication(ModuleTestCase):
|
|||
|
||||
changed = True
|
||||
|
||||
set_module_args(module_args)
|
||||
|
||||
# Run the module
|
||||
with mock_good_connection():
|
||||
with patch_keycloak_api(
|
||||
get_required_actions=return_value_required_actions,
|
||||
) as (
|
||||
mock_get_required_actions,
|
||||
mock_register_required_action,
|
||||
mock_update_required_action,
|
||||
mock_delete_required_action,
|
||||
):
|
||||
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_required_actions=return_value_required_actions,
|
||||
) as (
|
||||
mock_get_required_actions,
|
||||
mock_register_required_action,
|
||||
mock_update_required_action,
|
||||
mock_delete_required_action,
|
||||
):
|
||||
with self.assertRaises(AnsibleExitJson) as exec_info:
|
||||
self.module.main()
|
||||
|
||||
# Verify number of call on each mock
|
||||
self.assertEqual(len(mock_get_required_actions.mock_calls), 1)
|
||||
|
@ -386,20 +385,19 @@ class TestKeycloakAuthentication(ModuleTestCase):
|
|||
|
||||
changed = False
|
||||
|
||||
set_module_args(module_args)
|
||||
|
||||
# Run the module
|
||||
with mock_good_connection():
|
||||
with patch_keycloak_api(
|
||||
get_required_actions=return_value_required_actions,
|
||||
) as (
|
||||
mock_get_required_actions,
|
||||
mock_register_required_action,
|
||||
mock_update_required_action,
|
||||
mock_delete_required_action,
|
||||
):
|
||||
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_required_actions=return_value_required_actions,
|
||||
) as (
|
||||
mock_get_required_actions,
|
||||
mock_register_required_action,
|
||||
mock_update_required_action,
|
||||
mock_delete_required_action,
|
||||
):
|
||||
with self.assertRaises(AnsibleExitJson) as exec_info:
|
||||
self.module.main()
|
||||
|
||||
# Verify number of call on each mock
|
||||
self.assertEqual(len(mock_get_required_actions.mock_calls), 1)
|
||||
|
@ -537,20 +535,19 @@ class TestKeycloakAuthentication(ModuleTestCase):
|
|||
|
||||
changed = True
|
||||
|
||||
set_module_args(module_args)
|
||||
|
||||
# Run the module
|
||||
with mock_good_connection():
|
||||
with patch_keycloak_api(
|
||||
get_required_actions=return_value_required_actions,
|
||||
) as (
|
||||
mock_get_required_actions,
|
||||
mock_register_required_action,
|
||||
mock_update_required_action,
|
||||
mock_delete_required_action,
|
||||
):
|
||||
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_required_actions=return_value_required_actions,
|
||||
) as (
|
||||
mock_get_required_actions,
|
||||
mock_register_required_action,
|
||||
mock_update_required_action,
|
||||
mock_delete_required_action,
|
||||
):
|
||||
with self.assertRaises(AnsibleExitJson) as exec_info:
|
||||
self.module.main()
|
||||
|
||||
# Verify number of call on each mock
|
||||
self.assertEqual(len(mock_get_required_actions.mock_calls), 1)
|
||||
|
@ -676,20 +673,19 @@ class TestKeycloakAuthentication(ModuleTestCase):
|
|||
|
||||
changed = True
|
||||
|
||||
set_module_args(module_args)
|
||||
|
||||
# Run the module
|
||||
with mock_good_connection():
|
||||
with patch_keycloak_api(
|
||||
get_required_actions=return_value_required_actions,
|
||||
) as (
|
||||
mock_get_required_actions,
|
||||
mock_register_required_action,
|
||||
mock_update_required_action,
|
||||
mock_delete_required_action,
|
||||
):
|
||||
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_required_actions=return_value_required_actions,
|
||||
) as (
|
||||
mock_get_required_actions,
|
||||
mock_register_required_action,
|
||||
mock_update_required_action,
|
||||
mock_delete_required_action,
|
||||
):
|
||||
with self.assertRaises(AnsibleExitJson) as exec_info:
|
||||
self.module.main()
|
||||
|
||||
# Verify number of call on each mock
|
||||
self.assertEqual(len(mock_get_required_actions.mock_calls), 1)
|
||||
|
@ -806,20 +802,19 @@ class TestKeycloakAuthentication(ModuleTestCase):
|
|||
|
||||
changed = False
|
||||
|
||||
set_module_args(module_args)
|
||||
|
||||
# Run the module
|
||||
with mock_good_connection():
|
||||
with patch_keycloak_api(
|
||||
get_required_actions=return_value_required_actions,
|
||||
) as (
|
||||
mock_get_required_actions,
|
||||
mock_register_required_action,
|
||||
mock_update_required_action,
|
||||
mock_delete_required_action,
|
||||
):
|
||||
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_required_actions=return_value_required_actions,
|
||||
) as (
|
||||
mock_get_required_actions,
|
||||
mock_register_required_action,
|
||||
mock_update_required_action,
|
||||
mock_delete_required_action,
|
||||
):
|
||||
with self.assertRaises(AnsibleExitJson) as exec_info:
|
||||
self.module.main()
|
||||
|
||||
# Verify number of call on each mock
|
||||
self.assertEqual(len(mock_get_required_actions.mock_calls), 1)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue