test: xpathΒΆ
xpath uses lxml xpath in conjunction with assertpy to validate task data.
This module combines the power of xpath and assertpy. In order to use this module it is somewhat necessary to be familiar with both of those. Links to them can be found below.
xpath cheatsheat <https://devhints.io/xpath>__assertpy <https://github.com/assertpy/assertpy>__
Examples:
[251]:
from nornir import InitNornir
from nornir_napalm.plugins.tasks import napalm_get, napalm_cli
from nornir_tests.plugins.functions import print_result
from nornir_tests.plugins.tasks import wrap_task
from nornir_tests.plugins.tests import xpath
nr = InitNornir(
inventory={
"plugin": "SimpleInventory",
"options": {
"host_file": "inventory/hosts.yaml",
"group_file": "inventory/groups.yaml",
"defaults_file": "inventory/defaults.yaml",
}
},
dry_run=True,
)