mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-23 02:41: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
|
@ -59,9 +59,9 @@ class TestPritunlUserInfo(ModuleTestCase):
|
|||
with self.patch_get_pritunl_users(
|
||||
side_effect=PritunlListUserMock
|
||||
) as user_mock:
|
||||
set_module_args({})
|
||||
with self.assertRaises(AnsibleFailJson):
|
||||
self.module.main()
|
||||
with set_module_args({}):
|
||||
with self.assertRaises(AnsibleFailJson):
|
||||
self.module.main()
|
||||
|
||||
self.assertEqual(org_mock.call_count, 0)
|
||||
self.assertEqual(user_mock.call_count, 0)
|
||||
|
@ -75,15 +75,15 @@ class TestPritunlUserInfo(ModuleTestCase):
|
|||
side_effect=PritunlListUserMock
|
||||
) as user_mock:
|
||||
with self.assertRaises(AnsibleFailJson) as result:
|
||||
set_module_args(
|
||||
with set_module_args(
|
||||
{
|
||||
"pritunl_api_token": "token",
|
||||
"pritunl_api_secret": "secret",
|
||||
"pritunl_url": "https://pritunl.domain.com",
|
||||
"organization": "Unknown",
|
||||
}
|
||||
)
|
||||
self.module.main()
|
||||
):
|
||||
self.module.main()
|
||||
|
||||
self.assertEqual(org_mock.call_count, 1)
|
||||
self.assertEqual(user_mock.call_count, 0)
|
||||
|
@ -103,15 +103,15 @@ class TestPritunlUserInfo(ModuleTestCase):
|
|||
side_effect=PritunlListUserMock
|
||||
) as user_mock:
|
||||
with self.assertRaises(AnsibleExitJson) as result:
|
||||
set_module_args(
|
||||
with set_module_args(
|
||||
{
|
||||
"pritunl_api_token": "token",
|
||||
"pritunl_api_secret": "secret",
|
||||
"pritunl_url": "https://pritunl.domain.com",
|
||||
"organization": "GumGum",
|
||||
}
|
||||
)
|
||||
self.module.main()
|
||||
):
|
||||
self.module.main()
|
||||
|
||||
self.assertEqual(org_mock.call_count, 1)
|
||||
self.assertEqual(user_mock.call_count, 1)
|
||||
|
@ -137,7 +137,7 @@ class TestPritunlUserInfo(ModuleTestCase):
|
|||
side_effect=PritunlListUserMock
|
||||
) as user_mock:
|
||||
with self.assertRaises(AnsibleExitJson) as result:
|
||||
set_module_args(
|
||||
with set_module_args(
|
||||
{
|
||||
"pritunl_api_token": "token",
|
||||
"pritunl_api_secret": "secret",
|
||||
|
@ -146,8 +146,8 @@ class TestPritunlUserInfo(ModuleTestCase):
|
|||
"user_name": expected_user_name,
|
||||
"user_type": expected_user_type,
|
||||
}
|
||||
)
|
||||
self.module.main()
|
||||
):
|
||||
self.module.main()
|
||||
|
||||
self.assertEqual(org_mock.call_count, 1)
|
||||
self.assertEqual(user_mock.call_count, 1)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue