Fix pylint issue in pce functional tests
[transportpce.git] / tests / transportpce_tests / pce / test02_pce_400G.py
index 7be2c48c684864c412e12f278d1fc7bbcf9dc948..db4cb4e2915f67dacfa796dccf0ceb604c5b4f39 100644 (file)
@@ -8,15 +8,19 @@
 # http://www.apache.org/licenses/LICENSE-2.0
 ##############################################################################
 
+# pylint: disable=invalid-name
 # pylint: disable=no-member
 # pylint: disable=too-many-public-methods
 
 import unittest
 import os
+# pylint: disable=wrong-import-order
 import sys
 import time
 import requests
 sys.path.append('transportpce_tests/common/')
+# pylint: disable=wrong-import-position
+# pylint: disable=import-error
 import test_utils  # nopep8
 
 
@@ -28,31 +32,37 @@ class TransportPCE400Gtesting(unittest.TestCase):
 
     @classmethod
     def setUpClass(cls):
+        # pylint: disable=bare-except
+        sample_files_parsed = False
         try:
-            sample_files_parsed = False
             TOPO_BI_DIR_FILE = os.path.join(os.path.dirname(os.path.realpath(__file__)),
-                                            "..", "..", "sample_configs", "honeynode-topo400G.json")
-            with open(TOPO_BI_DIR_FILE, 'r') as topo_bi_dir:
+                                            "..", "..", "sample_configs",
+                                            "honeynode-topo400G.json")
+            with open(TOPO_BI_DIR_FILE, 'r', encoding='utf-8') as topo_bi_dir:
                 cls.topo_bi_dir_data = topo_bi_dir.read()
 
             OTN_TOPO_BI_DIR_FILE = os.path.join(os.path.dirname(os.path.realpath(__file__)),
-                                                "..", "..", "sample_configs", "honeynode-otntopo400G.json")
-            with open(OTN_TOPO_BI_DIR_FILE, 'r') as otn_topo_bi_dir:
+                                                "..", "..", "sample_configs",
+                                                "honeynode-otntopo400G.json")
+            with open(OTN_TOPO_BI_DIR_FILE, 'r', encoding='utf-8') as otn_topo_bi_dir:
                 cls.otn_topo_bi_dir_data = otn_topo_bi_dir.read()
 
             OTUC4_OTN_TOPO_BI_DIR_FILE = os.path.join(os.path.dirname(os.path.realpath(__file__)),
-                                                      "..", "..", "sample_configs", "honeynode-otntopo400GwithOTUC4.json")
-            with open(OTUC4_OTN_TOPO_BI_DIR_FILE, 'r') as otuc4_otn_topo_bi_dir:
+                                                      "..", "..", "sample_configs",
+                                                      "honeynode-otntopo400GwithOTUC4.json")
+            with open(OTUC4_OTN_TOPO_BI_DIR_FILE, 'r', encoding='utf-8') as otuc4_otn_topo_bi_dir:
                 cls.otuc4_otn_topo_bi_dir_data = otuc4_otn_topo_bi_dir.read()
 
             ODUC4_OTN_TOPO_BI_DIR_FILE = os.path.join(os.path.dirname(os.path.realpath(__file__)),
-                                                      "..", "..", "sample_configs", "honeynode-otntopo400GwithODUC4.json")
-            with open(ODUC4_OTN_TOPO_BI_DIR_FILE, 'r') as oduc4_otn_topo_bi_dir:
+                                                      "..", "..", "sample_configs",
+                                                      "honeynode-otntopo400GwithODUC4.json")
+            with open(ODUC4_OTN_TOPO_BI_DIR_FILE, 'r', encoding='utf-8') as oduc4_otn_topo_bi_dir:
                 cls.oduc4_otn_topo_bi_dir_data = oduc4_otn_topo_bi_dir.read()
 
             PORT_MAPPING_FILE = os.path.join(os.path.dirname(os.path.realpath(__file__)),
-                                             "..", "..", "sample_configs", "pce_portmapping_71.json")
-            with open(PORT_MAPPING_FILE, 'r') as port_mapping:
+                                             "..", "..", "sample_configs",
+                                             "pce_portmapping_71.json")
+            with open(PORT_MAPPING_FILE, 'r', encoding='utf-8') as port_mapping:
                 cls.port_mapping_data = port_mapping.read()
             sample_files_parsed = True
         except PermissionError as err:
@@ -77,6 +87,7 @@ class TransportPCE400Gtesting(unittest.TestCase):
         print("all processes killed")
 
     def setUp(self):  # instruction executed before each test method
+        # pylint: disable=consider-using-f-string
         print("execution of {}".format(self.id().split(".")[-1]))
         time.sleep(1)
 
@@ -136,13 +147,17 @@ class TransportPCE400Gtesting(unittest.TestCase):
     # Path Computation success
     def test_05_path_computation_OTUC4_xpdr_bi(self):
         response = test_utils.path_computation_request("request-1", "service-OTUC4",
-                                                       {"service-rate": "400", "clli": "NodeA",
-                                                           "service-format": "OTU", "node-id": "XPDR-A2",
-                                                           "rx-direction": {"port": {"port-device-name": "XPDR-A2-XPDR2"}}
+                                                       {"service-rate": "400",
+                                                        "clli": "NodeA",
+                                                        "service-format": "OTU",
+                                                        "node-id": "XPDR-A2",
+                                                        "tx-direction": {"port": {"port-device-name": "XPDR-A2-XPDR2"}}
                                                         },
-                                                       {"service-rate": "400", "clli": "NodeC",
-                                                           "service-format": "OTU", "node-id": "XPDR-C2",
-                                                           "rx-direction": {"port": {"port-device-name": "XPDR-C2-XPDR2"}}
+                                                       {"service-rate": "400",
+                                                        "clli": "NodeC",
+                                                        "service-format": "OTU",
+                                                        "node-id": "XPDR-C2",
+                                                        "tx-direction": {"port": {"port-device-name": "XPDR-C2-XPDR2"}}
                                                         })
         self.assertEqual(response.status_code, requests.codes.ok)
         res = response.json()
@@ -181,13 +196,17 @@ class TransportPCE400Gtesting(unittest.TestCase):
     # Path Computation success
     def test_07_path_computation_ODUC4_xpdr_bi(self):
         response = test_utils.path_computation_request("request-1", "service-ODUC4",
-                                                       {"service-rate": "400", "clli": "NodeA", "service-format": "ODU",
-                                                           "node-id": "XPDR-A2",
-                                                           "tx-direction": {"port": {"port-device-name": "XPDR-A2-XPDR2"}}
+                                                       {"service-rate": "400",
+                                                        "clli": "NodeA",
+                                                        "service-format": "ODU",
+                                                        "node-id": "XPDR-A2",
+                                                        "tx-direction": {"port": {"port-device-name": "XPDR-A2-XPDR2"}}
                                                         },
-                                                       {"service-rate": "400", "clli": "NodeC", "service-format": "ODU",
-                                                           "node-id": "XPDR-C2",
-                                                           "tx-direction": {"port": {"port-device-name": "XPDR-C2-XPDR2"}}
+                                                       {"service-rate": "400",
+                                                        "clli": "NodeC",
+                                                        "service-format": "ODU",
+                                                        "node-id": "XPDR-C2",
+                                                        "tx-direction": {"port": {"port-device-name": "XPDR-C2-XPDR2"}}
                                                         })
         self.assertEqual(response.status_code, requests.codes.ok)
         res = response.json()
@@ -214,11 +233,15 @@ class TransportPCE400Gtesting(unittest.TestCase):
     # Path Computation success
     def test_09_path_computation_100G_xpdr_bi(self):
         response = test_utils.path_computation_request("request-1", "service-100GE",
-                                                       {"service-rate": "100", "clli": "NodeA", "service-format": "Ethernet",
+                                                       {"service-rate": "100",
+                                                        "clli": "NodeA",
+                                                        "service-format": "Ethernet",
                                                         "node-id": "XPDR-A2",
                                                         "tx-direction": {"port": {"port-device-name": "XPDR-A2-XPDR2",
                                                                                   "port-name": "XPDR2-CLIENT1"}}},
-                                                       {"service-rate": "100", "clli": "NodeC", "service-format": "Ethernet",
+                                                       {"service-rate": "100",
+                                                        "clli": "NodeC",
+                                                        "service-format": "Ethernet",
                                                         "node-id": "XPDR-C2",
                                                         "tx-direction": {"port": {"port-device-name": "XPDR-C2-XPDR2",
                                                                                   "port-name": "XPDR2-CLIENT1"}}})