test(rack): cover peer_port below 1 in validate_links
All checks were successful
Build docs site / build (push) Successful in 52s
Build slides / build (push) Successful in 1m10s

This commit is contained in:
sjat 2026-06-24 15:13:15 +02:00
parent e54cbb3f0f
commit 773fec952f

View file

@ -384,6 +384,14 @@ def test_validate_links_rejects_peer_port_over_count():
gen_rack.validate_links(items, hw_index) gen_rack.validate_links(items, hw_index)
def test_validate_links_rejects_peer_port_below_one():
items = [item(hostname="mf01", rack_u=2, u_height=1, rack_face="front",
links=[{"local": "eth0", "peer": "sw01", "peer_port": 0}])]
hw_index = {"sw01": item(hostname="sw01", kind="switch", ports=24)}
with pytest.raises(gen_rack.SchemaError):
gen_rack.validate_links(items, hw_index)
def test_validate_links_accepts_peer_without_ports(): def test_validate_links_accepts_peer_without_ports():
items = [item(hostname="mf01", rack_u=2, u_height=1, rack_face="front", items = [item(hostname="mf01", rack_u=2, u_height=1, rack_face="front",
links=[{"local": "eth0", "peer": "rtr01", "peer_port": 99}])] links=[{"local": "eth0", "peer": "rtr01", "peer_port": 99}])]