From 90274645a9cb9e4ea378aad8d593d10565a952e2 Mon Sep 17 00:00:00 2001 From: Vidya Ambadipudi <vidya.ambadipudi@geant.org> Date: Thu, 20 Aug 2020 14:57:30 +0200 Subject: [PATCH] added test for multiple category classification --- inventory_provider/tasks/worker.py | 1 + test/test_worker_utils.py | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/inventory_provider/tasks/worker.py b/inventory_provider/tasks/worker.py index c38f0474..995574e7 100644 --- a/inventory_provider/tasks/worker.py +++ b/inventory_provider/tasks/worker.py @@ -699,6 +699,7 @@ class PollerServiceCategory(str, enum.Enum): def _classify_interface(ifc): + if ifc['description'].startswith('SRV_MDVPN CUSTOMER'): yield PollerServiceCategory.MDVPN diff --git a/test/test_worker_utils.py b/test/test_worker_utils.py index aa9f03ec..20f22a78 100644 --- a/test/test_worker_utils.py +++ b/test/test_worker_utils.py @@ -139,34 +139,41 @@ def test_build_subnet_db(mocked_worker_module): } ], [ - 'SRV_L3VPN CUSTOMER ESNET LHCONE SRF9928635 | ASN293 | GEN-EEX-ESNET-LHCONE', # noqa + 'SRV_L3VPN CUSTOMER ESNET LHCONE SRF9928635 | ASN293 | GEN-EEX-ESNET-LHCONE', { worker.PollerServiceCategory.LHCONE_CUST } ], [ - 'SRV_L3VPN RE KREONET LHCONE SRF17072 | ASN17579', # noqa + 'SRV_L3VPN RE KREONET LHCONE SRF17072 | ASN17579', { worker.PollerServiceCategory.LHCONE_PEER } ], [ - 'SRV_IAS CUSTOMER ACONET SRF9947199 IASPS | ASN1853', # noqa + 'SRV_IAS CUSTOMER ACONET SRF9947199 IASPS | ASN1853', { worker.PollerServiceCategory.IAS } ], [ - 'SRV_GLOBAL CUSTOMER HBKU SRF18085 | ASN34945|', # noqa + 'SRV_GLOBAL CUSTOMER HBKU SRF18085 | ASN34945|', { worker.PollerServiceCategory.RE_CUST } ], [ - 'SRV_GLOBAL RE_INTERCONNECT HBKU SRF18085 | ASN34945|', # noqa + 'SRV_GLOBAL RE_INTERCONNECT HBKU SRF18085 | ASN34945|', { worker.PollerServiceCategory.RE_PEER } + ], + [ + 'SRV_MDVPN CUSTOMER LHCONE SRV_L3VPN CUSTOMER SRF18085 | ASN34945|', + { + worker.PollerServiceCategory.MDVPN, + worker.PollerServiceCategory.LHCONE_CUST + } ] ]) def test_interface_classification(description, expected_categories): -- GitLab