Skip to content
Snippets Groups Projects
Commit efc7012f authored by Erik Reid's avatar Erik Reid
Browse files

validate interface list format

parent 17daebd3
No related branches found
No related tags found
No related merge requests found
import os
from inventory_provider import netconf
import jsonschema
from lxml import etree
import pytest
from inventory_provider import netconf
TEST_DATA_DIR = os.path.join(os.path.dirname(__file__), 'data')
......@@ -23,9 +27,33 @@ class MockedJunosDevice(object):
pass
def test_query_doc_and_validate(mocker, router, data_config):
@pytest.fixture
def netconf_doc(mocker, router, data_config):
mocker.patch(
'inventory_provider.netconf.Device',
MockedJunosDevice)
netconf.load_config(router, data_config['ssh'])
return netconf.load_config(router, data_config['ssh'])
def test_query_doc_and_validate(netconf_doc):
schema = {
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {"type": "string"},
"description": {"type": "string"}
},
"required": ["name", "description"],
"additionalProperties": False
}
}
interfaces = list(netconf.list_interfaces(netconf_doc))
jsonschema.validate(interfaces, schema)
assert interfaces # at least shouldn't be empty
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment