diff --git a/test/test_update.py b/test/test_update.py index f4ab22416f295a72d9960a489f2e79b046ab6625..ec4e6f45f071674d45eda023b1260cc7af142db9 100644 --- a/test/test_update.py +++ b/test/test_update.py @@ -10,7 +10,8 @@ TEST_INTERFACES = [ "name": "ge-0/0/8", "bundle": [], "bundle-parents": [], - "description": "PHY CUSTOMER GEANT CORPORATE SRF000001 | GEANT Corporate to MX1.LON - Via Vodafone", # noqa: E501 + "description": "PHY CUSTOMER GEANT CORPORATE SRF000001 | GEANT Corporate to MX1.LON - Via Vodafone", + # noqa: E501 "circuits": [ { "id": 679232, @@ -280,6 +281,41 @@ TEST_INTERFACES = [ }], "ipv4": [], "ipv6": [] + }, + { + + "router": "rt1.fra.de.geant.net", + "name": "xe-11/2/5.300", + "bundle": [], + "bundle-parents": [], + "description": "SRV_GLOBAL CUSTOMER AZSCIENCENET #AZSCIENCENET-AP1 $GS-00433 | ASN202993 |", + "circuits": [ + { + "id": 723799, + "name": "AZSCIENCENET-AP1", + "type": "GEANT IP", + "status": "operational" + } + ], + "snmp-index": 1033, + "dashboards": [ + "EAP", + "NREN", + "RE_CUST" + ], + "dashboard_info": { + "name": "AZSCIENCENET", + "interface_type": "LOGICAL" + }, + "dashboards_info": [ + { + "name": "AZSCIENCENET", + "interface_type": "LOGICAL" + } + ], + "port_type": "SERVICE", + "ipv4": [], + "ipv6": [] } ] @@ -288,7 +324,7 @@ NREN_INTERFACES = [ "router": "mx1.dub2.ie.geant.net", "name": "xe-0/0/0", "bundle": [ - "ae10" + "ae10" ], "bundle-parents": [], "description": "PHY CUSTOMER HEANET P_AE10 SRF9948758 | HEANET-AP2-LL3", # noqa: E501 @@ -313,7 +349,7 @@ NREN_INTERFACES = [ "router": "mx1.dub2.ie.geant.net", "name": "xe-1/0/1", "bundle": [ - "ae10" + "ae10" ], "bundle-parents": [], "description": "PHY CUSTOMER HEANET P_AE10 SRF0000001 | HEANET-AP2-LL2", # noqa: E501 @@ -338,7 +374,7 @@ NREN_INTERFACES = [ "router": "mx1.dub2.ie.geant.net", "name": "xe-1/1/0", "bundle": [ - "ae10" + "ae10" ], "bundle-parents": [], "description": "PHY CUSTOMER HEANET P_AE10 SRF9925903 | HEANET-AP2-LL1", # noqa: E501 @@ -364,9 +400,9 @@ NREN_INTERFACES = [ "name": "ae10", "bundle": [], "bundle-parents": [ - "xe-0/0/0", - "xe-1/0/1", - "xe-1/1/0" + "xe-0/0/0", + "xe-1/0/1", + "xe-1/1/0" ], "description": "LAG CUSTOMER HEANET SRF9925909 | HEANET-AP2-LAG", "circuits": [], @@ -391,9 +427,9 @@ NREN_INTERFACES = [ "name": "ae10.12", "bundle": [], "bundle-parents": [ - "xe-0/0/0", - "xe-1/0/1", - "xe-1/1/0" + "xe-0/0/0", + "xe-1/0/1", + "xe-1/1/0" ], "description": "SRV_GLOBAL CUSTOMER HEANET #HEANET-AP2 | ASN1213 | ", "circuits": [ @@ -429,9 +465,9 @@ NREN_INTERFACES = [ "name": "ae10.30", "bundle": [], "bundle-parents": [ - "xe-0/0/0", - "xe-1/0/1", - "xe-1/1/0" + "xe-0/0/0", + "xe-1/0/1", + "xe-1/1/0" ], "description": "SRV_MDVPN CUSTOMER HEANET AP2 #HEANET-BGP-LU-CoC-1 |", # noqa: E501 "circuits": [ @@ -465,9 +501,9 @@ NREN_INTERFACES = [ "name": "ae10.333", "bundle": [], "bundle-parents": [ - "xe-0/0/0", - "xe-1/0/1", - "xe-1/1/0" + "xe-0/0/0", + "xe-1/0/1", + "xe-1/1/0" ], "description": "SRV_IAS CUSTOMER HEANET #HEANET-AP2-IAS IASPS | ASN1213 ", # noqa: E501 "circuits": [ @@ -503,9 +539,9 @@ NREN_INTERFACES = [ "name": "ae10.1214", "bundle": [], "bundle-parents": [ - "xe-0/0/0", - "xe-1/0/1", - "xe-1/1/0" + "xe-0/0/0", + "xe-1/0/1", + "xe-1/1/0" ], "description": "SRV_L2CIRCUIT CUSTOMER HEANET GEANT #ams-dub2-HEANET-RARE-21061 |", # noqa: E501 "circuits": [ @@ -529,9 +565,9 @@ NREN_INTERFACES = [ "interface_type": "LOGICAL" }, { - "name": "HEANET", - "interface_type": "LOGICAL" - }], + "name": "HEANET", + "interface_type": "LOGICAL" + }], "ipv4": [], "ipv6": [] } @@ -634,26 +670,26 @@ def populate_inventory(data_config): ("NREN Access", [], ['ASNET-AM', 'CESNET', 'GEANT', 'KIAE', 'LITNET', 'SWITCH']), ("NREN Access", ["GEANT", "KIAE"], ['ASNET-AM', 'CESNET', 'LITNET', 'SWITCH']), ( - "NREN Access", - [], - ["ASNET-AM", "LITNET", "CESNET", "GEANT", "KIAE", "SWITCH"], + "NREN Access", + [], + ["ASNET-AM", "LITNET", "CESNET", "GEANT", "KIAE", "SWITCH"], ), ( - "NREN Access", - ["ASNET-AM", "GEANT"], - ["LITNET", "CESNET", "KIAE", "SWITCH"], + "NREN Access", + ["ASNET-AM", "GEANT"], + ["LITNET", "CESNET", "KIAE", "SWITCH"], ), ("testfolder", ["GEANT"], ["KIAE", "SWITCH"]), ], ) def test_provision_nren_folder( - folder_name, - excluded_nrens, - expected_nrens, - data_config, - mock_grafana, - reporting_provider, - populate_inventory, + folder_name, + excluded_nrens, + expected_nrens, + data_config, + mock_grafana, + reporting_provider, + populate_inventory, ): dashboards = { "NREN": { @@ -700,7 +736,7 @@ def test_provision_nren_folder( @responses.activate def test_provision( - data_config, mocker, mock_grafana, reporting_provider, populate_inventory + data_config, mocker, mock_grafana, reporting_provider, populate_inventory ): mock_grafana.create_datasource( { @@ -739,7 +775,7 @@ def test_provision( @responses.activate def test_provision_re_peer_dashboard( - mocker, data_config, mock_grafana, reporting_provider, populate_inventory + mocker, data_config, mock_grafana, reporting_provider, populate_inventory ): interfaces = [ { @@ -785,3 +821,56 @@ def test_provision_re_peer_dashboard( assert "traffic" in panels[4]["title"] assert "IPv6" in panels[5]["title"] assert "Interfaces" in panels[6]["title"] + + +@responses.activate +@pytest.mark.parametrize( + "folder_name, dashboard_id, expected_dashboard_count", + [ + ('NREN Access', 'NREN', 6), # uncategorized interfaces + ('EAP Access', 'EAP', 1) # EAP categorized interfaces + ] +) +def test_provision_nren_category( + folder_name, + dashboard_id, + expected_dashboard_count, + data_config, + mock_grafana, + reporting_provider, + populate_inventory, +): + nren_interfaces = [ + iface for iface in TEST_INTERFACES if "NREN" in iface["dashboards"] + ] + dashboards = { + "NREN": { + "tag": ["customers"], + "folder_name": "NREN Access", + "interfaces": nren_interfaces, + }, + "EAP": { + "tag": ["eap"], + "folder_name": "EAP Access", + "interfaces": nren_interfaces, + }, + } + populate_inventory( + { + "/poller/interfaces": NREN_INTERFACES, + "/data/interfaces": NREN_INTERFACES, + "/poller/eumetsat-multicast": EUMETSAT_MULTICAST, + } + ) + + services = fetch_services(data_config['reporting_provider']) + + result = provision_folder( + mock_grafana.request, + folder_name, + dashboards[dashboard_id], + services, + "testdatasource", + [], + ) + assert len(result) == expected_dashboard_count