Improve some func. tests variables naming
[transportpce.git] / tests / transportpce_tests / 2.2.1 / test02_topo_portmapping.py
index a2b8bf189ea7bae7f4a22180d09603cf77912046..586b882f1868933b174bae4144b0974485f0f862 100644 (file)
 import unittest
 import time
 import requests
+# pylint: disable=wrong-import-order
 import sys
 sys.path.append('transportpce_tests/common/')
+# pylint: disable=wrong-import-position
+# pylint: disable=import-error
 import test_utils_rfc8040  # nopep8
 
 
@@ -47,13 +50,13 @@ class TransportPCEtesting(unittest.TestCase):
 
     # Verify the termination points of the ROADMA
     def test_02_compareOpenroadmTopologyPortMapping_rdm(self):
-        responseTopo = test_utils_rfc8040.get_request(test_utils_rfc8040.URL_CONFIG_ORDM_TOPO)
-        resTopo = responseTopo.json()
-        firstEntry = resTopo['ietf-network:network'][0]['node']
+        resTopo = test_utils_rfc8040.get_ietf_network_request('openroadm-topology', 'config')
+        self.assertEqual(resTopo['status_code'], requests.codes.ok)
         nbMapCumul = 0
         nbMappings = 0
-        for i in range(0, len(firstEntry)):
-            nodeId = firstEntry[i]['node-id']
+        for node in resTopo['network'][0]['node']:
+            nodeId = node['node-id']
+            # pylint: disable=consider-using-f-string
             print("nodeId={}".format(nodeId))
             nodeMapId = nodeId.split("-")[0] + "-" + nodeId.split("-")[1]
             print("nodeMapId={}".format(nodeMapId))
@@ -61,10 +64,9 @@ class TransportPCEtesting(unittest.TestCase):
             self.assertEqual(response['status_code'], requests.codes.ok)
             responseMapList = test_utils_rfc8040.get_portmapping(nodeMapId)
             nbMappings = len(responseMapList['nodes'][0]['mapping']) - nbMapCumul
-            nbTp = len(firstEntry[i]['ietf-network-topology:termination-point'])
             nbMapCurrent = 0
-            for j in range(0, nbTp):
-                tpId = firstEntry[i]['ietf-network-topology:termination-point'][j]['tp-id']
+            for tp in node['ietf-network-topology:termination-point']:
+                tpId = tp['tp-id']
                 if (not "CP" in tpId) and (not "CTP" in tpId):
                     responseMap = test_utils_rfc8040.portmapping_request(nodeMapId, tpId)
                     self.assertEqual(responseMap['status_code'], requests.codes.ok)