mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 21:00:22 -07:00
nso_verify handle leaf-list in 4.5 and identityref (#37393)
NSO verify did not handle leaf-list value verification in 4.5 and later due to changes made for configuration writing made. map prefix for identityref types in verification.
This commit is contained in:
parent
1fd9a616a4
commit
6308047dc9
4 changed files with 51 additions and 26 deletions
|
@ -61,6 +61,10 @@ class MockResponse(object):
|
|||
|
||||
|
||||
def mock_call(calls, url, timeout, data=None, headers=None, method=None):
|
||||
if len(calls) == 0:
|
||||
raise ValueError('no call mock for method {0}({1})'.format(
|
||||
url, data))
|
||||
|
||||
result = calls[0]
|
||||
del calls[0]
|
||||
|
||||
|
@ -99,6 +103,8 @@ class TestNsoModule(unittest.TestCase):
|
|||
self.assertEqual(result['changed'], changed, result)
|
||||
|
||||
for key, value in kwargs.items():
|
||||
if key not in result:
|
||||
self.fail("{0} not in result {1}".format(key, result))
|
||||
self.assertEqual(value, result[key])
|
||||
|
||||
return result
|
||||
|
|
|
@ -51,6 +51,7 @@ class TestNsoVerify(nso_module.TestNsoModule):
|
|||
def test_nso_verify_violation(self, open_url_mock):
|
||||
devices_schema = nso_module.load_fixture('devices_schema.json')
|
||||
device_schema = nso_module.load_fixture('device_schema.json')
|
||||
description_schema = nso_module.load_fixture('description_schema.json')
|
||||
|
||||
calls = [
|
||||
MockResponse('login', {}, 200, '{}', {'set-cookie': 'id'}),
|
||||
|
@ -61,6 +62,7 @@ class TestNsoVerify(nso_module.TestNsoModule):
|
|||
MockResponse('get_schema', {'path': '/ncs:devices/device'}, 200, '{"result": %s}' % (json.dumps(device_schema, ))),
|
||||
MockResponse('exists', {'path': '/ncs:devices/device{ce0}'}, 200, '{"result": {"exists": true}}'),
|
||||
MockResponse('get_value', {'path': '/ncs:devices/device{ce0}/description'}, 200, '{"result": {"value": "In Violation"}}'),
|
||||
MockResponse('get_schema', {'path': '/ncs:devices/device/description'}, 200, '{"result": %s}' % (json.dumps(description_schema, ))),
|
||||
MockResponse('logout', {}, 200, '{"result": {}}'),
|
||||
]
|
||||
open_url_mock.side_effect = lambda *args, **kwargs: nso_module.mock_call(calls, *args, **kwargs)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue