improve functional tests pylint score
[transportpce.git] / tests / transportpce_tests / 1.2.1 / test_portmapping.py
index 424e6f7d6d723b059b963f61d569c954dfe3b9ee..91f82770c836786ae7144633706c1e20e615d9b9 100644 (file)
 ##############################################################################
 
 import json
-import os
-import psutil
-import requests
 import signal
-import shutil
-import subprocess
-import time
 import unittest
+import time
+import requests
+import psutil
 import test_utils
 
 
@@ -28,22 +25,22 @@ class TransportPCEPortMappingTesting(unittest.TestCase):
     odl_process = None
     restconf_baseurl = "http://localhost:8181/restconf"
 
-#START_IGNORE_XTESTING
+# START_IGNORE_XTESTING
 
     @classmethod
     def setUpClass(cls):
-        print ("starting honeynode1...")
+        print("starting honeynode1...")
         cls.honeynode_process1 = test_utils.start_xpdra_honeynode()
         time.sleep(20)
 
-        print ("starting honeynode2...")
+        print("starting honeynode2...")
         cls.honeynode_process2 = test_utils.start_roadma_honeynode()
         time.sleep(20)
 
-        print ("starting opendaylight...")
+        print("starting opendaylight...")
         cls.odl_process = test_utils.start_tpce()
         time.sleep(60)
-        print ("opendaylight started")
+        print("opendaylight started")
 
     @classmethod
     def tearDownClass(cls):
@@ -64,10 +61,10 @@ class TransportPCEPortMappingTesting(unittest.TestCase):
         cls.honeynode_process2.wait()
 
     def setUp(self):
-        print ("execution of {}".format(self.id().split(".")[-1]))
+        print("execution of {}".format(self.id().split(".")[-1]))
         time.sleep(10)
 
-#END_IGNORE_XTESTING
+# END_IGNORE_XTESTING
 
 #    def test_01_restconfAPI(self):
 #        url = ("{}/operational/network-topology:network-topology/topology/"
@@ -88,13 +85,13 @@ class TransportPCEPortMappingTesting(unittest.TestCase):
 #         res = response.json()
 #         self.assertIn(
 #             {"error-type":"application", "error-tag":"data-missing",
-#              "error-message":"Request could not be completed because the relevant data model content does not exist "},
+#             "error-message":"Request could not be completed because the relevant data model content does not exist "},
 #             res['errors']['error'])
 
     def test_01_rdm_device_connected(self):
         url = ("{}/config/network-topology:"
                "network-topology/topology/topology-netconf/node/ROADMA01"
-              .format(self.restconf_baseurl))
+               .format(self.restconf_baseurl))
         data = {"node": [{
             "node-id": "ROADMA01",
             "netconf-node-topology:username": "admin",
@@ -135,10 +132,10 @@ class TransportPCEPortMappingTesting(unittest.TestCase):
         res = response.json()
         self.assertEqual(
             {u'node-info': {u'node-type': u'rdm',
-             u'node-ip-address': u'127.0.0.12',
-             u'node-clli': u'NodeA',
-             u'openroadm-version': u'1.2.1', u'node-vendor': u'vendorA',
-             u'node-model': u'2'}},
+                            u'node-ip-address': u'127.0.0.12',
+                            u'node-clli': u'NodeA',
+                            u'openroadm-version': u'1.2.1', u'node-vendor': u'vendorA',
+                            u'node-model': u'2'}},
             res)
         time.sleep(3)
 
@@ -187,7 +184,7 @@ class TransportPCEPortMappingTesting(unittest.TestCase):
     def test_07_xpdr_device_connected(self):
         url = ("{}/config/network-topology:"
                "network-topology/topology/topology-netconf/node/XPDRA01"
-              .format(self.restconf_baseurl))
+               .format(self.restconf_baseurl))
         data = {"node": [{
             "node-id": "XPDRA01",
             "netconf-node-topology:username": "admin",
@@ -228,10 +225,10 @@ class TransportPCEPortMappingTesting(unittest.TestCase):
         res = response.json()
         self.assertEqual(
             {u'node-info': {u'node-type': u'xpdr',
-             u'node-ip-address': u'127.0.0.10',
-             u'node-clli': u'NodeA',
-             u'openroadm-version': u'1.2.1', u'node-vendor': u'vendorA',
-             u'node-model': u'1'}},
+                            u'node-ip-address': u'127.0.0.10',
+                            u'node-clli': u'NodeA',
+                            u'openroadm-version': u'1.2.1', u'node-vendor': u'vendorA',
+                            u'node-model': u'1'}},
             res)
         time.sleep(3)
 
@@ -332,12 +329,12 @@ class TransportPCEPortMappingTesting(unittest.TestCase):
 
     def test_16_xpdr_device_disconnected(self):
         url = ("{}/config/network-topology:"
-                "network-topology/topology/topology-netconf/node/XPDRA01"
+               "network-topology/topology/topology-netconf/node/XPDRA01"
                .format(self.restconf_baseurl))
         headers = {'content-type': 'application/json'}
         response = requests.request(
-             "DELETE", url, headers=headers,
-             auth=('admin', 'admin'))
+            "DELETE", url, headers=headers,
+            auth=('admin', 'admin'))
         self.assertEqual(response.status_code, requests.codes.ok)
         time.sleep(20)
 
@@ -350,8 +347,8 @@ class TransportPCEPortMappingTesting(unittest.TestCase):
         self.assertEqual(response.status_code, requests.codes.not_found)
         res = response.json()
         self.assertIn(
-            {"error-type":"application", "error-tag":"data-missing",
-             "error-message":"Request could not be completed because the relevant data model content does not exist"},
+            {"error-type": "application", "error-tag": "data-missing",
+             "error-message": "Request could not be completed because the relevant data model content does not exist"},
             res['errors']['error'])
 
     def test_18_xpdr_device_disconnected(self):
@@ -362,8 +359,8 @@ class TransportPCEPortMappingTesting(unittest.TestCase):
         self.assertEqual(response.status_code, requests.codes.not_found)
         res = response.json()
         self.assertIn(
-            {"error-type":"application", "error-tag":"data-missing",
-             "error-message":"Request could not be completed because the relevant data model content does not exist"},
+            {"error-type": "application", "error-tag": "data-missing",
+             "error-message": "Request could not be completed because the relevant data model content does not exist"},
             res['errors']['error'])
 
     def test_19_rdm_device_disconnected(self):
@@ -371,8 +368,8 @@ class TransportPCEPortMappingTesting(unittest.TestCase):
                .format(self.restconf_baseurl))
         headers = {'content-type': 'application/json'}
         response = requests.request(
-             "DELETE", url, headers=headers,
-             auth=('admin', 'admin'))
+            "DELETE", url, headers=headers,
+            auth=('admin', 'admin'))
         self.assertEqual(response.status_code, requests.codes.ok)
         time.sleep(20)
 
@@ -385,8 +382,8 @@ class TransportPCEPortMappingTesting(unittest.TestCase):
         self.assertEqual(response.status_code, requests.codes.not_found)
         res = response.json()
         self.assertIn(
-            {"error-type":"application", "error-tag":"data-missing",
-             "error-message":"Request could not be completed because the relevant data model content does not exist"},
+            {"error-type": "application", "error-tag": "data-missing",
+             "error-message": "Request could not be completed because the relevant data model content does not exist"},
             res['errors']['error'])
 
     def test_21_rdm_device_disconnected(self):
@@ -397,8 +394,8 @@ class TransportPCEPortMappingTesting(unittest.TestCase):
         self.assertEqual(response.status_code, requests.codes.not_found)
         res = response.json()
         self.assertIn(
-            {"error-type":"application", "error-tag":"data-missing",
-             "error-message":"Request could not be completed because the relevant data model content does not exist"},
+            {"error-type": "application", "error-tag": "data-missing",
+             "error-message": "Request could not be completed because the relevant data model content does not exist"},
             res['errors']['error'])