mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-04 23:44:00 -07: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:
parent
402f725424
commit
a1781d09dd
84 changed files with 4043 additions and 4302 deletions
|
@ -49,9 +49,9 @@ class TestPritunlOrgInfo(ModuleTestCase):
|
|||
with self.patch_get_pritunl_organizations(
|
||||
side_effect=PritunlListOrganizationMock
|
||||
) as org_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)
|
||||
|
||||
|
@ -61,14 +61,14 @@ class TestPritunlOrgInfo(ModuleTestCase):
|
|||
side_effect=PritunlEmptyOrganizationMock
|
||||
) as org_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",
|
||||
}
|
||||
)
|
||||
self.module.main()
|
||||
):
|
||||
self.module.main()
|
||||
|
||||
self.assertEqual(org_mock.call_count, 1)
|
||||
|
||||
|
@ -81,15 +81,15 @@ class TestPritunlOrgInfo(ModuleTestCase):
|
|||
side_effect=PritunlListOrganizationMock
|
||||
) as org_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",
|
||||
"org": "GumGum",
|
||||
}
|
||||
)
|
||||
self.module.main()
|
||||
):
|
||||
self.module.main()
|
||||
|
||||
self.assertEqual(org_mock.call_count, 1)
|
||||
|
||||
|
@ -102,15 +102,15 @@ class TestPritunlOrgInfo(ModuleTestCase):
|
|||
side_effect=PritunlListOrganizationMock
|
||||
) as org_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",
|
||||
"org": "Unknown",
|
||||
}
|
||||
)
|
||||
self.module.main()
|
||||
):
|
||||
self.module.main()
|
||||
|
||||
self.assertEqual(org_mock.call_count, 1)
|
||||
|
||||
|
@ -123,14 +123,14 @@ class TestPritunlOrgInfo(ModuleTestCase):
|
|||
side_effect=PritunlListOrganizationMock
|
||||
) as org_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",
|
||||
}
|
||||
)
|
||||
self.module.main()
|
||||
):
|
||||
self.module.main()
|
||||
|
||||
self.assertEqual(org_mock.call_count, 1)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue