diff --git a/tests/test_yang_paths.py b/tests/test_yang_paths.py new file mode 100644 index 0000000..72ab3c2 --- /dev/null +++ b/tests/test_yang_paths.py @@ -0,0 +1,69 @@ +"""Tests for YANG path helpers.""" + +from gnmi_eos.yang.paths import ( + AfiSafi, + BGP, + EVPN, + MLAG, + VXLAN, + FabricSubscriptions, + Interfaces, + Loopbacks, + PortChannel, + System, + VLANs, +) + + +def test_interfaces_paths(): + assert Interfaces.interface("Ethernet1") == "/interfaces/interface[name=Ethernet1]" + assert Interfaces.state("Ethernet1") == "/interfaces/interface[name=Ethernet1]/state" + assert Interfaces.counters("Ethernet1") == "/interfaces/interface[name=Ethernet1]/state/counters" + assert Interfaces.oper_status("Ethernet1") == "/interfaces/interface[name=Ethernet1]/state/oper-status" + + +def test_loopbacks_paths(): + assert Loopbacks.LOOPBACK0 == "/interfaces/interface[name=Loopback0]" + assert Loopbacks.interface(1) == "/interfaces/interface[name=Loopback1]" + + +def test_vlan_paths(): + assert VLANs.vlan(100) == "/network-instances/network-instance[name=default]/vlans/vlan[vlan-id=100]" + assert VLANs.svi(100) == "/interfaces/interface[name=Vlan100]" + + +def test_bgp_paths(): + assert "/bgp/neighbors/neighbor" in BGP.NEIGHBORS + assert "10.0.0.1" in BGP.neighbor_state("10.0.0.1") + assert "session-state" in BGP.neighbor_session_state("10.0.0.1") + assert AfiSafi.L2VPN_EVPN == "L2VPN_EVPN" + + +def test_vxlan_paths(): + assert "Vxlan1" in VXLAN.CONFIG + assert "vlan-to-vni" in VXLAN.vlan_to_vni(100) + assert "vrf-to-vni" in VXLAN.vrf_to_vni("PROD") + + +def test_mlag_paths(): + assert MLAG.CONFIG == "/arista/eos/mlag/config" + + +def test_evpn_paths(): + assert EVPN.ROOT == "/arista/eos/evpn" + assert "TENANT_A" in EVPN.instance("TENANT_A") + + +def test_system_paths(): + assert System.HOSTNAME == "/system/config/hostname" + + +def test_port_channel_paths(): + assert "Port-Channel1" in PortChannel.interface(1) + assert "aggregation" in PortChannel.aggregation(1) + + +def test_fabric_subscriptions(): + subs = FabricSubscriptions.all() + assert len(subs) == 3 + assert str(FabricSubscriptions.INTERFACE_STATE) == "/interfaces/interface/state"