{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# test: xpath\n", "\n", "[xpath](../api/tasks.rst#nornir_tests.plugins.tests.xpath) uses lxml xpath in conjunction with assertpy to validate task data.\n", "\n", "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.\n", "\n", "* `xpath cheatsheat `__\n", "* `assertpy `__\n", "\n", "\n", "Examples:" ] }, { "cell_type": "code", "execution_count": 251, "metadata": {}, "outputs": [], "source": [ "from nornir import InitNornir\n", "from nornir_napalm.plugins.tasks import napalm_get, napalm_cli\n", "\n", "from nornir_tests.plugins.functions import print_result\n", "from nornir_tests.plugins.tasks import wrap_task\n", "from nornir_tests.plugins.tests import xpath\n", "\n", "nr = InitNornir(\n", " inventory={\n", " \"plugin\": \"SimpleInventory\",\n", " \"options\": {\n", " \"host_file\": \"inventory/hosts.yaml\",\n", " \"group_file\": \"inventory/groups.yaml\",\n", " \"defaults_file\": \"inventory/defaults.yaml\",\n", " }\n", " },\n", " dry_run=True,\n", ")" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3.8.2 64-bit ('.venv': venv)", "language": "python", "name": "python38264bitvenvvenv1c35bb63d8ff4e6aa6d1792b190afa1b" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.2-final" } }, "nbformat": 4, "nbformat_minor": 4 }