summaryrefslogtreecommitdiffstats
path: root/tests/topotests/mgmt_oper/test_yanglib.py
blob: e094ca544374218c27b56dfc8bc19791aa0a8c28 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env python
# SPDX-License-Identifier: ISC
# -*- coding: utf-8 eval: (blacken-mode 1) -*-
#
# September 17 2024, Christian Hopps <chopps@labn.net>
#
# Copyright (c) 2024, LabN Consulting, L.L.C.
#

import json
import pytest
from lib.topogen import Topogen

pytestmark = [pytest.mark.staticd, pytest.mark.mgmtd]


@pytest.fixture(scope="module")
def tgen(request):
    "Setup/Teardown the environment and provide tgen argument to tests"

    topodef = {"s1": ("r1",)}

    tgen = Topogen(topodef, request.module.__name__)
    tgen.start_topology()

    router_list = tgen.routers()
    for rname, router in router_list.items():
        router.load_frr_config("frr-yanglib.conf")

    tgen.start_router()
    yield tgen
    tgen.stop_topology()


def test_yang_lib(tgen):
    if tgen.routers_have_failure():
        pytest.skip(tgen.errors)

    r1 = tgen.gears["r1"].net
    output = r1.cmd_nostatus(
        "vtysh -c 'show mgmt get-data /ietf-yang-library:yang-library'"
    )
    ret = json.loads(output)
    loaded_modules = ret['ietf-yang-library:yang-library']['module-set'][0]['module']
    assert len(loaded_modules) > 10, "Modules missing from yang-library"