From a0606b61935ac197d0e8e5b3f8c47cab084756a9 Mon Sep 17 00:00:00 2001 From: lou lecrivain Date: Wed, 17 Jul 2024 11:04:17 +0200 Subject: [PATCH] test internal serializer vendor representation + err on unsupported vendor --- cosmo/tests/test_case_vendor_unknown.yaml | 16 ++++++++++++++++ cosmo/tests/test_serializer.py | 17 +++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 cosmo/tests/test_case_vendor_unknown.yaml diff --git a/cosmo/tests/test_case_vendor_unknown.yaml b/cosmo/tests/test_case_vendor_unknown.yaml new file mode 100644 index 0000000..8249462 --- /dev/null +++ b/cosmo/tests/test_case_vendor_unknown.yaml @@ -0,0 +1,16 @@ +device_list: +- device_type: + slug: r2000 + id: '1999' + interfaces: [] + name: TEST0001 + platform: + manufacturer: + slug: ACME + slug: coyote-0-2-1-rc1 + primary_ip4: + address: 45.139.136.10/24 + serial: 4242 + staticroute_set: [] +l2vpn_list: [] +vrf_list: [] diff --git a/cosmo/tests/test_serializer.py b/cosmo/tests/test_serializer.py index 0032d6b..8c54dcc 100644 --- a/cosmo/tests/test_serializer.py +++ b/cosmo/tests/test_serializer.py @@ -35,6 +35,23 @@ def get_switch_sd_from_path(path): return list(map(lambda s: s.serialize(), get_switch_s_from_path(path))) +def test_router_platforms(capsys): + [juniper_s] = get_router_s_from_path("./test_case_2.yaml") + assert juniper_s.mgmt_routing_instance == "mgmt_junos" + assert juniper_s.mgmt_interface == "fxp0" + assert juniper_s.bmc_interface == None + assert juniper_s.lo_interface == "lo0" + + [rtbrick_s] = get_router_s_from_path("./test_case_l3vpn.yml") + assert rtbrick_s.mgmt_routing_instance == "mgmt" + assert rtbrick_s.mgmt_interface == "ma1" + assert rtbrick_s.bmc_interface == "bmc0" + assert rtbrick_s.lo_interface == "lo-0/0/0" + + get_router_s_from_path("./test_case_vendor_unknown.yaml") + assert "unsupported platform vendor: ACME" in capsys.readouterr().err + + def test_router_physical_interface(): [sd] = get_router_sd_from_path("./test_case_1.yaml")