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

filter test router list by those with netconf data available

parent d12917d0
No related branches found
No related tags found
No related merge requests found
import glob
import os
import re
from lxml import etree
......@@ -12,14 +13,22 @@ TEST_DATA_DIRNAME = os.path.realpath(os.path.join(
def pytest_generate_tests(metafunc):
filename = os.path.join(TEST_DATA_DIRNAME, "junosspace-devices.xml")
with open(filename) as f:
doc = etree.fromstring(f.read().encode('utf-8'))
routers = []
for name in doc.xpath('//devices/device/name/text()'):
m = re.match('^(mx[1|2].*)\.re0', name)
if m:
routers.append({'hostname': m.group(1) + '.geant.net'})
metafunc.parametrize(
"router",
list([r['hostname'] for r in routers]))
def _junosspace_hosts():
filename = os.path.join(TEST_DATA_DIRNAME, "junosspace-devices.xml")
with open(filename) as f:
doc = etree.fromstring(f.read().encode('utf-8'))
for name in doc.xpath('//devices/device/name/text()'):
m = re.match(r'^(mx[12].*)\.re0', name)
if m:
yield m.group(1) + '.geant.net'
# TODO: can we really not get netconf data for all routers?
def _available_netconf_hosts():
for fn in glob.glob(os.path.join(TEST_DATA_DIRNAME, '*-netconf.xml')):
m = re.match('(.*)-netconf.xml', os.path.basename(fn))
assert m # sanity
yield m.group(1)
routers = list(set(_junosspace_hosts()) & set(_available_netconf_hosts()))
metafunc.parametrize("router", routers)
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