From 6fe500a1bf557eb44d22584ac6bf7c924f12c47f Mon Sep 17 00:00:00 2001 From: "guillaume.lambert" Date: Mon, 7 Sep 2020 16:44:51 +0200 Subject: [PATCH] fix some pylint issues and use a "#pylint disable=" comment to eliminate false positives JIRA: TRNSPRTPCE-320 Signed-off-by: guillaume.lambert Change-Id: I4a741f9f30f6d8e2e2ea209ad44f936cdaf6150f --- .../transportpce_tests/1.2.1/test_end2end.py | 1 + tests/transportpce_tests/1.2.1/test_gnpy.py | 2 ++ tests/transportpce_tests/1.2.1/test_olm.py | 3 +- tests/transportpce_tests/1.2.1/test_pce.py | 2 ++ .../1.2.1/test_portmapping.py | 1 + .../test_renderer_service_path_nominal.py | 1 + .../1.2.1/test_topoPortMapping.py | 9 ++++-- .../transportpce_tests/1.2.1/test_topology.py | 16 ++++++++-- .../transportpce_tests/2.2.1/test_end2end.py | 1 + tests/transportpce_tests/2.2.1/test_olm.py | 3 +- .../2.2.1/test_otn_end2end.py | 19 ++++++------ .../2.2.1/test_otn_renderer.py | 1 + .../2.2.1/test_otn_sh_renderer.py | 1 + .../2.2.1/test_otn_topology.py | 3 ++ .../2.2.1/test_portmapping.py | 1 + .../test_renderer_service_path_nominal.py | 1 + tests/transportpce_tests/2.2.1/test_tapi.py | 4 +++ .../2.2.1/test_topoPortMapping.py | 1 + .../transportpce_tests/2.2.1/test_topology.py | 16 ++++++++-- tests/transportpce_tests/common/__init__.py | 0 tests/transportpce_tests/common/test_utils.py | 30 +++++++++++-------- 21 files changed, 85 insertions(+), 31 deletions(-) create mode 100644 tests/transportpce_tests/common/__init__.py diff --git a/tests/transportpce_tests/1.2.1/test_end2end.py b/tests/transportpce_tests/1.2.1/test_end2end.py index 5266a6095..43c034813 100644 --- a/tests/transportpce_tests/1.2.1/test_end2end.py +++ b/tests/transportpce_tests/1.2.1/test_end2end.py @@ -127,6 +127,7 @@ class TransportPCEFulltesting(unittest.TestCase): @classmethod def tearDownClass(cls): + # pylint: disable=not-an-iterable for process in cls.processes: test_utils.shutdown_process(process) print("all processes killed") diff --git a/tests/transportpce_tests/1.2.1/test_gnpy.py b/tests/transportpce_tests/1.2.1/test_gnpy.py index 0a77c0ff9..80a92bf0d 100644 --- a/tests/transportpce_tests/1.2.1/test_gnpy.py +++ b/tests/transportpce_tests/1.2.1/test_gnpy.py @@ -29,6 +29,7 @@ class TransportGNPYtesting(unittest.TestCase): @classmethod def setUpClass(cls): + # pylint: disable=bare-except try: sample_files_parsed = False TOPO_CLLINET_FILE = os.path.join(os.path.dirname(os.path.realpath(__file__)), @@ -63,6 +64,7 @@ class TransportGNPYtesting(unittest.TestCase): @classmethod def tearDownClass(cls): + # pylint: disable=not-an-iterable for process in cls.processes: test_utils.shutdown_process(process) print("all processes killed") diff --git a/tests/transportpce_tests/1.2.1/test_olm.py b/tests/transportpce_tests/1.2.1/test_olm.py index 0d4aca507..f7155e8bc 100644 --- a/tests/transportpce_tests/1.2.1/test_olm.py +++ b/tests/transportpce_tests/1.2.1/test_olm.py @@ -29,6 +29,7 @@ class TransportOlmTesting(unittest.TestCase): @classmethod def tearDownClass(cls): + # pylint: disable=not-an-iterable for process in cls.processes: test_utils.shutdown_process(process) print("all processes killed") @@ -428,7 +429,7 @@ class TransportOlmTesting(unittest.TestCase): self.assertIn('Request processed', res["output"]["result"]) time.sleep(10) - """to test case where SRG where the xpdr is connected to has no optical range data""" + #"""to test case where SRG where the xpdr is connected to has no optical range data""" def test_31_connect_xprdA_to_roadmA(self): response = test_utils.connect_xpdr_to_rdm_request("XPDRA01", "1", "2", diff --git a/tests/transportpce_tests/1.2.1/test_pce.py b/tests/transportpce_tests/1.2.1/test_pce.py index 55aab56d9..e7e255f91 100644 --- a/tests/transportpce_tests/1.2.1/test_pce.py +++ b/tests/transportpce_tests/1.2.1/test_pce.py @@ -28,6 +28,7 @@ class TransportPCEtesting(unittest.TestCase): @classmethod def setUpClass(cls): + # pylint: disable=bare-except try: sample_files_parsed = False TOPO_BI_DIR_FILE = os.path.join(os.path.dirname(os.path.realpath(__file__)), @@ -63,6 +64,7 @@ class TransportPCEtesting(unittest.TestCase): @classmethod def tearDownClass(cls): + # pylint: disable=not-an-iterable for process in cls.processes: test_utils.shutdown_process(process) print("all processes killed") diff --git a/tests/transportpce_tests/1.2.1/test_portmapping.py b/tests/transportpce_tests/1.2.1/test_portmapping.py index 6024ca236..51694b568 100644 --- a/tests/transportpce_tests/1.2.1/test_portmapping.py +++ b/tests/transportpce_tests/1.2.1/test_portmapping.py @@ -29,6 +29,7 @@ class TransportPCEPortMappingTesting(unittest.TestCase): @classmethod def tearDownClass(cls): + # pylint: disable=not-an-iterable for process in cls.processes: test_utils.shutdown_process(process) print("all processes killed") diff --git a/tests/transportpce_tests/1.2.1/test_renderer_service_path_nominal.py b/tests/transportpce_tests/1.2.1/test_renderer_service_path_nominal.py index 3f7ff41e0..24b24230d 100644 --- a/tests/transportpce_tests/1.2.1/test_renderer_service_path_nominal.py +++ b/tests/transportpce_tests/1.2.1/test_renderer_service_path_nominal.py @@ -29,6 +29,7 @@ class TransportPCERendererTesting(unittest.TestCase): @classmethod def tearDownClass(cls): + # pylint: disable=not-an-iterable for process in cls.processes: test_utils.shutdown_process(process) print("all processes killed") diff --git a/tests/transportpce_tests/1.2.1/test_topoPortMapping.py b/tests/transportpce_tests/1.2.1/test_topoPortMapping.py index 48b501fa7..683b04a48 100644 --- a/tests/transportpce_tests/1.2.1/test_topoPortMapping.py +++ b/tests/transportpce_tests/1.2.1/test_topoPortMapping.py @@ -11,6 +11,8 @@ # pylint: disable=no-member # pylint: disable=too-many-public-methods +# a pylint false positive due to unittest +# pylint: disable=no-self-use import time import unittest @@ -29,6 +31,7 @@ class TransportPCEtesting(unittest.TestCase): @classmethod def tearDownClass(cls): + # pylint: disable=not-an-iterable for process in cls.processes: test_utils.shutdown_process(process) print("all processes killed") @@ -42,7 +45,7 @@ class TransportPCEtesting(unittest.TestCase): self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201) # Verify the termination points of the ROADMA - def test_02_compareOpenroadmTopologyPortMapping_rdm(self): + def test_02_compare_Openroadm_topology_portmapping_rdm(self): responseTopo = test_utils.get_ordm_topo_request("") resTopo = responseTopo.json() nbNode = len(resTopo['network'][0]['node']) @@ -67,8 +70,8 @@ class TransportPCEtesting(unittest.TestCase): self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201) # #Verify the termination points related to XPDR - def test_05_compareOpenroadmTopologyPortMapping_xpdr(self): - self.test_02_compareOpenroadmTopologyPortMapping_rdm() + def test_05_compare_Openroadm_topology_portmapping_xpdr(self): + self.test_02_compare_Openroadm_topology_portmapping_rdm() # Disconnect the XPDRA def test_06_disconnect_device(self): diff --git a/tests/transportpce_tests/1.2.1/test_topology.py b/tests/transportpce_tests/1.2.1/test_topology.py index 827a30c4a..e088b6d7f 100644 --- a/tests/transportpce_tests/1.2.1/test_topology.py +++ b/tests/transportpce_tests/1.2.1/test_topology.py @@ -11,6 +11,7 @@ # pylint: disable=no-member # pylint: disable=too-many-public-methods +# pylint: disable=too-many-lines import time import unittest @@ -29,6 +30,7 @@ class TransportPCETopologyTesting(unittest.TestCase): @classmethod def tearDownClass(cls): + # pylint: disable=not-an-iterable for process in cls.processes: test_utils.shutdown_process(process) print("all processes killed") @@ -58,6 +60,7 @@ class TransportPCETopologyTesting(unittest.TestCase): self.assertEqual(res['network'][0]['node'][0]['org-openroadm-network:model'], '2') def test_04_getLinks_OpenroadmTopology(self): + # pylint: disable=redundant-unittest-assert response = test_utils.get_ordm_topo_request("") self.assertEqual(response.status_code, requests.codes.ok) res = response.json() @@ -98,6 +101,7 @@ class TransportPCETopologyTesting(unittest.TestCase): self.assertEqual(len(dropLink), 0) def test_05_getNodes_OpenRoadmTopology(self): + # pylint: disable=redundant-unittest-assert response = test_utils.get_ordm_topo_request("") res = response.json() # Tests related to nodes @@ -176,6 +180,7 @@ class TransportPCETopologyTesting(unittest.TestCase): self.assertEqual(res['network'][0]['node'][0]['org-openroadm-clli-network:clli'], 'NodeA') def test_08_getOpenRoadmNetwork(self): + # pylint: disable=redundant-unittest-assert response = test_utils.get_ordm_net_request() self.assertEqual(response.status_code, requests.codes.ok) res = response.json() @@ -195,6 +200,7 @@ class TransportPCETopologyTesting(unittest.TestCase): self.assertFalse(True) def test_09_getNodes_OpenRoadmTopology(self): + # pylint: disable=redundant-unittest-assert response = test_utils.get_ordm_topo_request("") res = response.json() # Tests related to nodes @@ -292,6 +298,7 @@ class TransportPCETopologyTesting(unittest.TestCase): self.assertEqual(response.status_code, requests.codes.ok) def test_12_getLinks_OpenRoadmTopology(self): + # pylint: disable=redundant-unittest-assert response = test_utils.get_ordm_topo_request("") self.assertEqual(response.status_code, requests.codes.ok) res = response.json() @@ -390,6 +397,7 @@ class TransportPCETopologyTesting(unittest.TestCase): self.assertEqual(len(listNode), 0) def test_17_getOpenRoadmNetwork(self): + # pylint: disable=redundant-unittest-assert response = test_utils.get_ordm_net_request() self.assertEqual(response.status_code, requests.codes.ok) res = response.json() @@ -419,6 +427,7 @@ class TransportPCETopologyTesting(unittest.TestCase): self.assertEqual(len(listNode), 0) def test_18_getROADMLinkOpenRoadmTopology(self): + # pylint: disable=redundant-unittest-assert response = test_utils.get_ordm_topo_request("") self.assertEqual(response.status_code, requests.codes.ok) res = response.json() @@ -499,13 +508,14 @@ class TransportPCETopologyTesting(unittest.TestCase): length = (res['network'][0]['ietf-network-topology:link'][i] ['org-openroadm-network-topology:OMS-attributes']['span']['link-concatenation'][0] ['SRLG-length']) - if (spanLoss != None) & (length != None): + if (spanLoss is not None) & (length is not None): find = True self.assertTrue(find) R2RLink.remove(link_id) self.assertEqual(len(R2RLink), 0) def test_20_getNodes_OpenRoadmTopology(self): + # pylint: disable=redundant-unittest-assert response = test_utils.get_ordm_topo_request("") res = response.json() # Tests related to nodes @@ -765,7 +775,7 @@ class TransportPCETopologyTesting(unittest.TestCase): 'org-openroadm-network-topology:OMS-attributes']['span']["engineered-spanloss"] length = res['network'][0]['ietf-network-topology:link'][i][ 'org-openroadm-network-topology:OMS-attributes']['span']['link-concatenation'][0]['SRLG-length'] - if (spanLoss != None) & (length != None): + if (spanLoss is not None) & (length is not None): find = True self.assertTrue(find) R2RLink.remove(link_id) @@ -787,6 +797,7 @@ class TransportPCETopologyTesting(unittest.TestCase): self.assertEqual(response.status_code, requests.codes.ok) def test_32_getNodes_OpenRoadmTopology(self): + # pylint: disable=redundant-unittest-assert response = test_utils.get_ordm_topo_request("") res = response.json() # Tests related to nodes @@ -907,6 +918,7 @@ class TransportPCETopologyTesting(unittest.TestCase): self.assertNotEqual(res['network'][0]['node'][i]['node-id'], 'XPDRA01') def test_38_getNodes_OpenRoadmTopology(self): + # pylint: disable=redundant-unittest-assert response = test_utils.get_ordm_topo_request("") res = response.json() # Tests related to nodes diff --git a/tests/transportpce_tests/2.2.1/test_end2end.py b/tests/transportpce_tests/2.2.1/test_end2end.py index b26f8937a..bc9b3a634 100644 --- a/tests/transportpce_tests/2.2.1/test_end2end.py +++ b/tests/transportpce_tests/2.2.1/test_end2end.py @@ -118,6 +118,7 @@ class TransportPCEFulltesting(unittest.TestCase): @classmethod def tearDownClass(cls): + # pylint: disable=not-an-iterable for process in cls.processes: test_utils.shutdown_process(process) print("all processes killed") diff --git a/tests/transportpce_tests/2.2.1/test_olm.py b/tests/transportpce_tests/2.2.1/test_olm.py index f7b331ccc..4a5e97b48 100644 --- a/tests/transportpce_tests/2.2.1/test_olm.py +++ b/tests/transportpce_tests/2.2.1/test_olm.py @@ -29,6 +29,7 @@ class TransportOlmTesting(unittest.TestCase): @classmethod def tearDownClass(cls): + # pylint: disable=not-an-iterable for process in cls.processes: test_utils.shutdown_process(process) print("all processes killed") @@ -429,7 +430,7 @@ class TransportOlmTesting(unittest.TestCase): self.assertIn('Request processed', res["output"]["result"]) time.sleep(10) - """to test case where SRG where the xpdr is connected to has no optical range data""" + #"""to test case where SRG where the xpdr is connected to has no optical range data""" def test_31_connect_xprdA_to_roadmA(self): response = test_utils.connect_xpdr_to_rdm_request("XPDR-A1", "1", "2", diff --git a/tests/transportpce_tests/2.2.1/test_otn_end2end.py b/tests/transportpce_tests/2.2.1/test_otn_end2end.py index ee0e0d109..d2208da6d 100644 --- a/tests/transportpce_tests/2.2.1/test_otn_end2end.py +++ b/tests/transportpce_tests/2.2.1/test_otn_end2end.py @@ -132,6 +132,7 @@ class TransportPCEtesting(unittest.TestCase): @classmethod def tearDownClass(cls): + # pylint: disable=not-an-iterable for process in cls.processes: test_utils.shutdown_process(process) print("all processes killed") @@ -497,12 +498,12 @@ class TransportPCEtesting(unittest.TestCase): self.assertEqual(nb_links, 4) for link in res['network'][0]['ietf-network-topology:link']: linkId = link['link-id'] - if (linkId == 'OTU4-SPDR-SA1-XPDR1-XPDR1-NETWORK1toSPDR-SC1-XPDR1-XPDR1-NETWORK1' or - linkId == 'OTU4-SPDR-SC1-XPDR1-XPDR1-NETWORK1toSPDR-SA1-XPDR1-XPDR1-NETWORK1'): + if (linkId in ('OTU4-SPDR-SA1-XPDR1-XPDR1-NETWORK1toSPDR-SC1-XPDR1-XPDR1-NETWORK1', + 'OTU4-SPDR-SC1-XPDR1-XPDR1-NETWORK1toSPDR-SA1-XPDR1-XPDR1-NETWORK1')): self.assertEqual(link['org-openroadm-otn-network-topology:available-bandwidth'], 0) self.assertEqual(link['org-openroadm-otn-network-topology:used-bandwidth'], 100000) - elif (linkId == 'ODU4-SPDR-SA1-XPDR1-XPDR1-NETWORK1toSPDR-SC1-XPDR1-XPDR1-NETWORK1' or - linkId == 'ODU4-SPDR-SC1-XPDR1-XPDR1-NETWORK1toSPDR-SA1-XPDR1-XPDR1-NETWORK1'): + elif (linkId in ('ODU4-SPDR-SA1-XPDR1-XPDR1-NETWORK1toSPDR-SC1-XPDR1-XPDR1-NETWORK1', + 'ODU4-SPDR-SC1-XPDR1-XPDR1-NETWORK1toSPDR-SA1-XPDR1-XPDR1-NETWORK1')): self.assertEqual(link['org-openroadm-otn-network-topology:available-bandwidth'], 100000) self.assertEqual(link['org-openroadm-otn-network-topology:used-bandwidth'], 0) self.assertEqual(link['transportpce-topology:otn-link-type'], 'ODTU4') @@ -748,8 +749,8 @@ class TransportPCEtesting(unittest.TestCase): self.assertEqual(nb_links, 4) for link in res['network'][0]['ietf-network-topology:link']: linkId = link['link-id'] - if (linkId == 'ODU4-SPDR-SA1-XPDR1-XPDR1-NETWORK1toSPDR-SC1-XPDR1-XPDR1-NETWORK1' or - linkId == 'ODU4-SPDR-SC1-XPDR1-XPDR1-NETWORK1toSPDR-SA1-XPDR1-XPDR1-NETWORK1'): + if (linkId in ('ODU4-SPDR-SA1-XPDR1-XPDR1-NETWORK1toSPDR-SC1-XPDR1-XPDR1-NETWORK1', + 'ODU4-SPDR-SC1-XPDR1-XPDR1-NETWORK1toSPDR-SA1-XPDR1-XPDR1-NETWORK1')): self.assertEqual(link['org-openroadm-otn-network-topology:available-bandwidth'], 90000) self.assertEqual(link['org-openroadm-otn-network-topology:used-bandwidth'], 10000) @@ -763,7 +764,7 @@ class TransportPCEtesting(unittest.TestCase): if tp['tp-id'] == 'XPDR1-NETWORK1': xpdrTpPortConAt = tp['org-openroadm-otn-network-topology:xpdr-tp-port-connection-attributes'] self.assertEqual(len(xpdrTpPortConAt['ts-pool']), 72) - tsPoolList = [i for i in range(1, 9)] + tsPoolList = list(range(1, 9)) self.assertNotIn(tsPoolList, xpdrTpPortConAt['ts-pool']) self.assertEqual(len(xpdrTpPortConAt['odtu-tpn-pool'][0]['tpn-pool']), 79) self.assertNotIn(1, xpdrTpPortConAt['odtu-tpn-pool'][0]['tpn-pool']) @@ -810,8 +811,8 @@ class TransportPCEtesting(unittest.TestCase): self.assertEqual(nb_links, 4) for link in res['network'][0]['ietf-network-topology:link']: linkId = link['link-id'] - if (linkId == 'ODU4-SPDR-SA1-XPDR1-XPDR1-NETWORK1toSPDR-SC1-XPDR1-XPDR1-NETWORK1' or - linkId == 'ODU4-SPDR-SC1-XPDR1-XPDR1-NETWORK1toSPDR-SA1-XPDR1-XPDR1-NETWORK1'): + if (linkId in ('ODU4-SPDR-SA1-XPDR1-XPDR1-NETWORK1toSPDR-SC1-XPDR1-XPDR1-NETWORK1', + 'ODU4-SPDR-SC1-XPDR1-XPDR1-NETWORK1toSPDR-SA1-XPDR1-XPDR1-NETWORK1')): self.assertEqual(link['org-openroadm-otn-network-topology:available-bandwidth'], 100000) self.assertEqual(link['org-openroadm-otn-network-topology:used-bandwidth'], 0) diff --git a/tests/transportpce_tests/2.2.1/test_otn_renderer.py b/tests/transportpce_tests/2.2.1/test_otn_renderer.py index ee670fd14..b8fd458ac 100644 --- a/tests/transportpce_tests/2.2.1/test_otn_renderer.py +++ b/tests/transportpce_tests/2.2.1/test_otn_renderer.py @@ -29,6 +29,7 @@ class TransportPCEtesting(unittest.TestCase): @classmethod def tearDownClass(cls): + # pylint: disable=not-an-iterable for process in cls.processes: test_utils.shutdown_process(process) print("all processes killed") diff --git a/tests/transportpce_tests/2.2.1/test_otn_sh_renderer.py b/tests/transportpce_tests/2.2.1/test_otn_sh_renderer.py index be4c5e7a7..26054626b 100644 --- a/tests/transportpce_tests/2.2.1/test_otn_sh_renderer.py +++ b/tests/transportpce_tests/2.2.1/test_otn_sh_renderer.py @@ -29,6 +29,7 @@ class TransportPCEtesting(unittest.TestCase): @classmethod def tearDownClass(cls): + # pylint: disable=not-an-iterable for process in cls.processes: test_utils.shutdown_process(process) print("all processes killed") diff --git a/tests/transportpce_tests/2.2.1/test_otn_topology.py b/tests/transportpce_tests/2.2.1/test_otn_topology.py index 751e9399f..bc2c28a90 100644 --- a/tests/transportpce_tests/2.2.1/test_otn_topology.py +++ b/tests/transportpce_tests/2.2.1/test_otn_topology.py @@ -30,6 +30,7 @@ class TransportPCEtesting(unittest.TestCase): @classmethod def tearDownClass(cls): + # pylint: disable=not-an-iterable for process in cls.processes: test_utils.shutdown_process(process) print("all processes killed") @@ -77,6 +78,7 @@ class TransportPCEtesting(unittest.TestCase): self.assertNotIn('ietf-network-topology:link', res['network'][0]) def test_05_getNodes_OpenRoadmTopology(self): + # pylint: disable=redundant-unittest-assert response = test_utils.get_ordm_topo_request("") res = response.json() # Tests related to nodes @@ -138,6 +140,7 @@ class TransportPCEtesting(unittest.TestCase): self.assertNotIn('ietf-network-topology:link', res['network'][0]) def test_07_getNodes_OtnTopology(self): + # pylint: disable=redundant-unittest-assert response = test_utils.get_otn_topo_request() res = response.json() self.assertEqual(response.status_code, requests.codes.ok) diff --git a/tests/transportpce_tests/2.2.1/test_portmapping.py b/tests/transportpce_tests/2.2.1/test_portmapping.py index 58db3fca6..7692c3246 100644 --- a/tests/transportpce_tests/2.2.1/test_portmapping.py +++ b/tests/transportpce_tests/2.2.1/test_portmapping.py @@ -29,6 +29,7 @@ class TransportPCEPortMappingTesting(unittest.TestCase): @classmethod def tearDownClass(cls): + # pylint: disable=not-an-iterable for process in cls.processes: test_utils.shutdown_process(process) print("all processes killed") diff --git a/tests/transportpce_tests/2.2.1/test_renderer_service_path_nominal.py b/tests/transportpce_tests/2.2.1/test_renderer_service_path_nominal.py index adb7a89a1..83fb14822 100644 --- a/tests/transportpce_tests/2.2.1/test_renderer_service_path_nominal.py +++ b/tests/transportpce_tests/2.2.1/test_renderer_service_path_nominal.py @@ -29,6 +29,7 @@ class TransportPCERendererTesting(unittest.TestCase): @classmethod def tearDownClass(cls): + # pylint: disable=not-an-iterable for process in cls.processes: test_utils.shutdown_process(process) print("all processes killed") diff --git a/tests/transportpce_tests/2.2.1/test_tapi.py b/tests/transportpce_tests/2.2.1/test_tapi.py index 9622da91b..496a33e65 100644 --- a/tests/transportpce_tests/2.2.1/test_tapi.py +++ b/tests/transportpce_tests/2.2.1/test_tapi.py @@ -10,6 +10,9 @@ # pylint: disable=no-member # pylint: disable=too-many-public-methods +# some pylint false positives specific to tapi test +# pylint: disable=unsubscriptable-object +# pylint: disable=unsupported-assignment-operation import os import sys @@ -54,6 +57,7 @@ class TransportTapitesting(unittest.TestCase): @classmethod def tearDownClass(cls): + # pylint: disable=not-an-iterable for process in cls.processes: test_utils.shutdown_process(process) print("all processes killed") diff --git a/tests/transportpce_tests/2.2.1/test_topoPortMapping.py b/tests/transportpce_tests/2.2.1/test_topoPortMapping.py index d74b42d19..66c0c23d3 100644 --- a/tests/transportpce_tests/2.2.1/test_topoPortMapping.py +++ b/tests/transportpce_tests/2.2.1/test_topoPortMapping.py @@ -29,6 +29,7 @@ class TransportPCEtesting(unittest.TestCase): @classmethod def tearDownClass(cls): + # pylint: disable=not-an-iterable for process in cls.processes: test_utils.shutdown_process(process) print("all processes killed") diff --git a/tests/transportpce_tests/2.2.1/test_topology.py b/tests/transportpce_tests/2.2.1/test_topology.py index 7ec1885b8..936ccfc5d 100644 --- a/tests/transportpce_tests/2.2.1/test_topology.py +++ b/tests/transportpce_tests/2.2.1/test_topology.py @@ -11,6 +11,7 @@ # pylint: disable=no-member # pylint: disable=too-many-public-methods +# pylint: disable=too-many-lines import unittest import time @@ -30,6 +31,7 @@ class TransportPCEtesting(unittest.TestCase): @classmethod def tearDownClass(cls): + # pylint: disable=not-an-iterable for process in cls.processes: test_utils.shutdown_process(process) print("all processes killed") @@ -60,6 +62,7 @@ class TransportPCEtesting(unittest.TestCase): self.assertEqual(res['network'][0]['node'][0]['org-openroadm-network:model'], 'model2') def test_04_getLinks_OpenroadmTopology(self): + # pylint: disable=redundant-unittest-assert response = test_utils.get_ordm_topo_request("") self.assertEqual(response.status_code, requests.codes.ok) res = response.json() @@ -100,6 +103,7 @@ class TransportPCEtesting(unittest.TestCase): self.assertEqual(len(dropLink), 0) def test_05_getNodes_OpenRoadmTopology(self): + # pylint: disable=redundant-unittest-assert response = test_utils.get_ordm_topo_request("") res = response.json() # Tests related to nodes @@ -178,6 +182,7 @@ class TransportPCEtesting(unittest.TestCase): self.assertEqual(res['network'][0]['node'][0]['org-openroadm-clli-network:clli'], 'NodeA') def test_08_getOpenRoadmNetwork(self): + # pylint: disable=redundant-unittest-assert response = test_utils.get_ordm_net_request() self.assertEqual(response.status_code, requests.codes.ok) res = response.json() @@ -197,6 +202,7 @@ class TransportPCEtesting(unittest.TestCase): self.assertFalse(True) def test_09_getNodes_OpenRoadmTopology(self): + # pylint: disable=redundant-unittest-assert response = test_utils.get_ordm_topo_request("") res = response.json() # Tests related to nodes @@ -294,6 +300,7 @@ class TransportPCEtesting(unittest.TestCase): self.assertEqual(response.status_code, requests.codes.ok) def test_12_getLinks_OpenRoadmTopology(self): + # pylint: disable=redundant-unittest-assert response = test_utils.get_ordm_topo_request("") self.assertEqual(response.status_code, requests.codes.ok) res = response.json() @@ -392,6 +399,7 @@ class TransportPCEtesting(unittest.TestCase): self.assertEqual(len(listNode), 0) def test_17_getOpenRoadmNetwork(self): + # pylint: disable=redundant-unittest-assert response = test_utils.get_ordm_net_request() self.assertEqual(response.status_code, requests.codes.ok) res = response.json() @@ -421,6 +429,7 @@ class TransportPCEtesting(unittest.TestCase): self.assertEqual(len(listNode), 0) def test_18_getROADMLinkOpenRoadmTopology(self): + # pylint: disable=redundant-unittest-assert response = test_utils.get_ordm_topo_request("") self.assertEqual(response.status_code, requests.codes.ok) res = response.json() @@ -500,13 +509,14 @@ class TransportPCEtesting(unittest.TestCase): 'org-openroadm-network-topology:OMS-attributes']['span']["engineered-spanloss"] length = res['network'][0]['ietf-network-topology:link'][i][ 'org-openroadm-network-topology:OMS-attributes']['span']['link-concatenation'][0]['SRLG-length'] - if (spanLoss != None) & (length != None): + if (spanLoss is not None) & (length is not None): find = True self.assertTrue(find) R2RLink.remove(link_id) self.assertEqual(len(R2RLink), 0) def test_20_getNodes_OpenRoadmTopology(self): + # pylint: disable=redundant-unittest-assert response = test_utils.get_ordm_topo_request("") res = response.json() # Tests related to nodes @@ -772,7 +782,7 @@ class TransportPCEtesting(unittest.TestCase): 'org-openroadm-network-topology:OMS-attributes']['span']["engineered-spanloss"] length = res['network'][0]['ietf-network-topology:link'][i][ 'org-openroadm-network-topology:OMS-attributes']['span']['link-concatenation'][0]['SRLG-length'] - if (spanLoss != None) & (length != None): + if (spanLoss is not None) & (length is not None): find = True self.assertTrue(find) R2RLink.remove(link_id) @@ -859,6 +869,7 @@ class TransportPCEtesting(unittest.TestCase): # 'ROADMC-DEG2-DEG2-CTP-TXRXtoROADMC-DEG1-DEG1-CTP-TXRX') def test_32_getNodes_OpenRoadmTopology(self): + # pylint: disable=redundant-unittest-assert response = test_utils.get_ordm_topo_request("") res = response.json() # Tests related to nodes @@ -979,6 +990,7 @@ class TransportPCEtesting(unittest.TestCase): self.assertNotEqual(res['network'][0]['node'][i]['node-id'], 'XPDR-A1') def test_38_getNodes_OpenRoadmTopology(self): + # pylint: disable=redundant-unittest-assert response = test_utils.get_ordm_topo_request("") res = response.json() # Tests related to nodes diff --git a/tests/transportpce_tests/common/__init__.py b/tests/transportpce_tests/common/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/transportpce_tests/common/test_utils.py b/tests/transportpce_tests/common/test_utils.py index 19121f53c..dd26aba79 100644 --- a/tests/transportpce_tests/common/test_utils.py +++ b/tests/transportpce_tests/common/test_utils.py @@ -136,7 +136,7 @@ def install_karaf_feature(feature_name: str): "..", "..", "..", "karaf", "target", "assembly", "bin", "client") return subprocess.run([executable], input='feature:install ' + feature_name + '\n feature:list | grep tapi \n logout \n', - universal_newlines=True) + universal_newlines=True, check=False) def get_request(url): @@ -153,11 +153,11 @@ def post_request(url, data): data=json.dumps(data), headers=TYPE_APPLICATION_JSON, auth=(ODL_LOGIN, ODL_PWD)) - else: - return requests.request( - "POST", url.format(RESTCONF_BASE_URL), - headers=TYPE_APPLICATION_JSON, - auth=(ODL_LOGIN, ODL_PWD)) + + return requests.request( + "POST", url.format(RESTCONF_BASE_URL), + headers=TYPE_APPLICATION_JSON, + auth=(ODL_LOGIN, ODL_PWD)) def post_xmlrequest(url, data): @@ -167,6 +167,7 @@ def post_xmlrequest(url, data): data=data, headers=TYPE_APPLICATION_XML, auth=(ODL_LOGIN, ODL_PWD)) + return None def put_request(url, data): @@ -351,11 +352,11 @@ def service_delete_request(servicename: str, def service_path_request(operation: str, servicename: str, wavenumber: str, nodes): attr = {"renderer:input": { - "renderer:service-name": servicename, - "renderer:wave-number": wavenumber, - "renderer:modulation-format": "qpsk", - "renderer:operation": operation, - "renderer:nodes": nodes}} + "renderer:service-name": servicename, + "renderer:wave-number": wavenumber, + "renderer:modulation-format": "qpsk", + "renderer:operation": operation, + "renderer:nodes": nodes}} return post_request(URL_SERVICE_PATH, attr) @@ -373,8 +374,8 @@ def otn_service_path_request(operation: str, servicename: str, servicerate: str, def create_ots_oms_request(nodeid: str, lcp: str): attr = {"input": { - "node-id": nodeid, - "logical-connection-point": lcp}} + "node-id": nodeid, + "logical-connection-point": lcp}} return post_request(URL_CREATE_OTS_OMS, attr) @@ -409,9 +410,11 @@ def start_honeynode(log_file: str, node_port: str, node_config_file_name: str): return subprocess.Popen( [HONEYNODE_EXECUTABLE, node_port, os.path.join(SAMPLES_DIRECTORY, node_config_file_name)], stdout=outfile, stderr=outfile) + return None def wait_until_log_contains(log_file, regexp, time_to_wait=20): + # pylint: disable=lost-exception stringfound = False filefound = False line = None @@ -457,4 +460,5 @@ class TimeOut: signal.alarm(self.seconds) def __exit__(self, type, value, traceback): + # pylint: disable=W0622 signal.alarm(0) -- 2.36.6