mirror of
https://github.com/ansible-collections/community.routeros.git
synced 2025-06-22 18:03:34 +02:00
Add regexp field to ip dns static (#142)
* Add regexp field to "ip dns static" * Change test_invalid_required_missing to use "ip dhcp-server" "ip dns static" requires name or regexp so it cannot be used in this test. * Add required_one_of attribute to APIData Used by "ip dns static" which requires either "name" or "regexp. * Add mutually_exclusive attribute to APIData Used by "ip dns static" where only one of "name" or "regexp" can be used. * Add changelog fragment
This commit is contained in:
parent
62da7dd4e3
commit
586edbc211
5 changed files with 98 additions and 4 deletions
|
@ -385,9 +385,9 @@ class TestRouterosApiModifyModule(ModuleTestCase):
|
|||
with self.assertRaises(AnsibleFailJson) as exc:
|
||||
args = self.config_module_args.copy()
|
||||
args.update({
|
||||
'path': 'ip dns static',
|
||||
'path': 'ip dhcp-server',
|
||||
'data': [{
|
||||
'address': '1.2.3.4',
|
||||
'interface': 'eth0',
|
||||
}],
|
||||
})
|
||||
set_module_args(args)
|
||||
|
@ -397,6 +397,40 @@ class TestRouterosApiModifyModule(ModuleTestCase):
|
|||
self.assertEqual(result['failed'], True)
|
||||
self.assertEqual(result['msg'], 'Every element in data must contain "name". For example, the element at index #1 does not provide it.')
|
||||
|
||||
def test_invalid_required_one_of_missing(self):
|
||||
with self.assertRaises(AnsibleFailJson) as exc:
|
||||
args = self.config_module_args.copy()
|
||||
args.update({
|
||||
'path': 'ip dns static',
|
||||
'data': [{
|
||||
'address': '192.168.88.1',
|
||||
}],
|
||||
})
|
||||
set_module_args(args)
|
||||
self.module.main()
|
||||
|
||||
result = exc.exception.args[0]
|
||||
self.assertEqual(result['failed'], True)
|
||||
self.assertEqual(result['msg'], 'Every element in data must contain one of "name", "regexp". For example, the element at index 1 does not provide it.')
|
||||
|
||||
def test_invalid_mutually_exclusive_both(self):
|
||||
with self.assertRaises(AnsibleFailJson) as exc:
|
||||
args = self.config_module_args.copy()
|
||||
args.update({
|
||||
'path': 'ip dns static',
|
||||
'data': [{
|
||||
'name': 'foo',
|
||||
'regexp': 'bar',
|
||||
'address': '192.168.88.1',
|
||||
}],
|
||||
})
|
||||
set_module_args(args)
|
||||
self.module.main()
|
||||
|
||||
result = exc.exception.args[0]
|
||||
self.assertEqual(result['failed'], True)
|
||||
self.assertEqual(result['msg'], 'Keys "name", "regexp" cannot be used at the same time at index 1.')
|
||||
|
||||
@patch('ansible_collections.community.routeros.plugins.modules.api_modify.compose_api_path',
|
||||
new=create_fake_path(('ip', 'dns', 'static'), START_IP_DNS_STATIC, read_only=True))
|
||||
def test_sync_list_idempotent(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue