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

ix_public_peers test

parent 45718f04
No related branches found
No related tags found
No related merge requests found
import os
import jsonschema
from lxml import etree
import pytest
import inventory_provider
from inventory_provider import juniper
TEST_DATA_DIRNAME = os.path.realpath(os.path.join(
inventory_provider.__path__[0],
'..',
'test',
'data'))
ROUTER_NAME = 'mx1.vie.at.geant.net'
@pytest.fixture
def netconf():
netconf_filename = os.path.join(
TEST_DATA_DIRNAME,
ROUTER_NAME + '-netconf.xml')
doc = etree.parse(netconf_filename)
juniper.validate_netconf_config(doc)
return doc
def test_ix_public_peers(netconf):
schema = {
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"name": {
"type": "string",
"oneOf": [
{"pattern": r'^(\d+\.){3}\d+$'},
{"pattern": r'^([a-f\d]{4}:){7}[a-f\d]{4}$'}
]
},
"description": {"type": "string"},
"as": {
"type": "object",
"properties": {
"local": {"type": "integer"},
"peer": {"type": "integer"},
},
"required": ["local", "peer"],
"additionalProperties": False
}
},
"required": ["name", "description", "as"],
"additionalProperties": False
}
for p in juniper.ix_public_peers(netconf):
jsonschema.validate(p, schema)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment