mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-05-04 16:21:28 -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
|
@ -56,19 +56,19 @@ class TestDNSimple_Info(ModuleTestCase):
|
|||
def test_with_no_parameters(self):
|
||||
"""Failure must occurs when all parameters are missing"""
|
||||
with self.assertRaises(AnsibleFailJson):
|
||||
set_module_args({})
|
||||
self.module.main()
|
||||
with set_module_args({}):
|
||||
self.module.main()
|
||||
|
||||
@with_httmock(zones_resp)
|
||||
def test_only_key_and_account(self):
|
||||
"""key and account will pass, returns domains"""
|
||||
account_id = "1234"
|
||||
with self.assertRaises(AnsibleExitJson) as exc_info:
|
||||
set_module_args({
|
||||
with set_module_args({
|
||||
"api_key": "abcd1324",
|
||||
"account_id": account_id
|
||||
})
|
||||
self.module.main()
|
||||
}):
|
||||
self.module.main()
|
||||
result = exc_info.exception.args[0]
|
||||
# nothing should change
|
||||
self.assertFalse(result['changed'])
|
||||
|
@ -80,12 +80,12 @@ class TestDNSimple_Info(ModuleTestCase):
|
|||
"""name and no record should not fail, returns the record"""
|
||||
name = "example.com"
|
||||
with self.assertRaises(AnsibleExitJson) as exc_info:
|
||||
set_module_args({
|
||||
with set_module_args({
|
||||
"api_key": "abcd1324",
|
||||
"name": "example.com",
|
||||
"account_id": "1234"
|
||||
})
|
||||
self.module.main()
|
||||
}):
|
||||
self.module.main()
|
||||
result = exc_info.exception.args[0]
|
||||
# nothing should change
|
||||
self.assertFalse(result['changed'])
|
||||
|
@ -97,13 +97,13 @@ class TestDNSimple_Info(ModuleTestCase):
|
|||
"""name and record should not fail, returns the record"""
|
||||
record = "example"
|
||||
with self.assertRaises(AnsibleExitJson) as exc_info:
|
||||
set_module_args({
|
||||
with set_module_args({
|
||||
"api_key": "abcd1324",
|
||||
"account_id": "1234",
|
||||
"name": "example.com",
|
||||
"record": "example"
|
||||
})
|
||||
self.module.main()
|
||||
}):
|
||||
self.module.main()
|
||||
result = exc_info.exception.args[0]
|
||||
# nothing should change
|
||||
self.assertFalse(result['changed'])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue