You've already forked community.general
mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-08-01 06:06:57 +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:
@ -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'])
|
||||
|
Reference in New Issue
Block a user