fix some pylint issues
[transportpce.git] / tests / transportpce_tests / 1.2.1 / test_renderer_service_path_nominal.py
index 9533a64f350737a90625d7524285b9b55b145bd1..68ee4102ba00bdaea74de5a97ff59a39beaf630a 100644 (file)
 #############################################################################
 
 import unittest
-import requests
-import time
-import subprocess
-import signal
 import json
-import os
-import psutil
-import shutil
-from unittest.result import failfast
-import test_utils
+import time
+#from unittest.result import failfast
+import requests
+from common import test_utils
 
 
 class TransportPCERendererTesting(unittest.TestCase):
 
-    honeynode_process1 = None
-    honeynode_process2 = None
-    odl_process = None
-    restconf_baseurl = "http://localhost:8181/restconf"
-
-# START_IGNORE_XTESTING
+    processes = None
 
     @classmethod
     def setUpClass(cls):
-        print("starting honeynode1...")
-        cls.honeynode_process1 = test_utils.start_xpdra_honeynode()
-        time.sleep(20)
-
-        print("starting honeynode2...")
-        cls.honeynode_process2 = test_utils.start_roadma_honeynode()
-        time.sleep(20)
-
-        print("starting opendaylight...")
-        cls.odl_process = test_utils.start_tpce()
-        time.sleep(60)
-        print("opendaylight started")
+        cls.processes = test_utils.start_tpce()
+        cls.processes = test_utils.start_sims(['xpdra', 'roadma'])
 
     @classmethod
     def tearDownClass(cls):
-        for child in psutil.Process(cls.odl_process.pid).children():
-            child.send_signal(signal.SIGINT)
-            child.wait()
-        cls.odl_process.send_signal(signal.SIGINT)
-        cls.odl_process.wait()
-        for child in psutil.Process(cls.honeynode_process1.pid).children():
-            child.send_signal(signal.SIGINT)
-            child.wait()
-        cls.honeynode_process1.send_signal(signal.SIGINT)
-        cls.honeynode_process1.wait()
-        for child in psutil.Process(cls.honeynode_process2.pid).children():
-            child.send_signal(signal.SIGINT)
-            child.wait()
-        cls.honeynode_process2.send_signal(signal.SIGINT)
-        cls.honeynode_process2.wait()
+        for process in cls.processes:
+            test_utils.shutdown_process(process)
+        print("all processes killed")
 
     def setUp(self):
         print("execution of {}".format(self.id().split(".")[-1]))
         time.sleep(10)
 
-# END_IGNORE_XTESTING
-
     def test_01_rdm_device_connected(self):
-        url = ("{}/config/network-topology:"
-               "network-topology/topology/topology-netconf/node/ROADMA01"
-               .format(self.restconf_baseurl))
-        data = {"node": [{
-            "node-id": "ROADMA01",
-            "netconf-node-topology:username": "admin",
-            "netconf-node-topology:password": "admin",
-            "netconf-node-topology:host": "127.0.0.1",
-            "netconf-node-topology:port": "17831",
-            "netconf-node-topology:tcp-only": "false",
-            "netconf-node-topology:pass-through": {}}]}
-        headers = {'content-type': 'application/json'}
-        response = requests.request(
-            "PUT", url, data=json.dumps(data), headers=headers,
-            auth=('admin', 'admin'))
-        self.assertEqual(response.status_code, requests.codes.created)
-        time.sleep(20)
+        response = test_utils.mount_device("ROADMA01", 'roadma')
+        self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201)
 
     def test_02_xpdr_device_connected(self):
-        url = ("{}/config/network-topology:"
-               "network-topology/topology/topology-netconf/node/XPDRA01"
-               .format(self.restconf_baseurl))
-        data = {"node": [{
-            "node-id": "XPDRA01",
-            "netconf-node-topology:username": "admin",
-            "netconf-node-topology:password": "admin",
-            "netconf-node-topology:host": "127.0.0.1",
-            "netconf-node-topology:port": "17830",
-            "netconf-node-topology:tcp-only": "false",
-            "netconf-node-topology:pass-through": {}}]}
-        headers = {'content-type': 'application/json'}
-        response = requests.request(
-            "PUT", url, data=json.dumps(data), headers=headers,
-            auth=('admin', 'admin'))
-        self.assertEqual(response.status_code, requests.codes.created)
-        time.sleep(20)
+        response = test_utils.mount_device("XPDRA01", 'xpdra')
+        self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201)
 
     def test_03_rdm_portmapping(self):
         url = ("{}/config/transportpce-portmapping:network/"
                "nodes/ROADMA01"
-               .format(self.restconf_baseurl))
-        headers = {'content-type': 'application/json'}
+               .format(test_utils.RESTCONF_BASE_URL))
         response = requests.request(
-            "GET", url, headers=headers, auth=('admin', 'admin'))
+            "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
         self.assertEqual(response.status_code, requests.codes.ok)
         res = response.json()
         self.assertIn(
@@ -129,26 +64,27 @@ class TransportPCERendererTesting(unittest.TestCase):
     def test_04_xpdr_portmapping(self):
         url = ("{}/config/transportpce-portmapping:network/"
                "nodes/XPDRA01"
-               .format(self.restconf_baseurl))
-        headers = {'content-type': 'application/json'}
+               .format(test_utils.RESTCONF_BASE_URL))
         response = requests.request(
-            "GET", url, headers=headers, auth=('admin', 'admin'))
+            "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
         self.assertEqual(response.status_code, requests.codes.ok)
         res = response.json()
         self.assertIn(
             {'supporting-port': '1', 'supporting-circuit-pack-name': '1/0/1-PLUG-NET',
              'logical-connection-point': 'XPDR1-NETWORK1', 'port-direction': 'bidirectional',
-             'connection-map-lcp': 'XPDR1-CLIENT1', 'port-qual': 'xpdr-network'},
+             'connection-map-lcp': 'XPDR1-CLIENT1', 'port-qual': 'xpdr-network',
+             'lcp-hash-val': '3b3ab304d2a6eb3c3623e52746dbb7aa'},
             res['nodes'][0]['mapping'])
         self.assertIn(
             {'supporting-port': 'C1',
              'supporting-circuit-pack-name': '1/0/C1-PLUG-CLIENT',
              'logical-connection-point': 'XPDR1-CLIENT1', 'port-direction': 'bidirectional',
-             'connection-map-lcp': 'XPDR1-NETWORK1', 'port-qual': 'xpdr-client'},
+             'connection-map-lcp': 'XPDR1-NETWORK1', 'port-qual': 'xpdr-client',
+             'lcp-hash-val': '64b8effe7ba72211420bf267d0ca1ae5'},
             res['nodes'][0]['mapping'])
 
     def test_05_service_path_create(self):
-        url = "{}/operations/transportpce-device-renderer:service-path".format(self.restconf_baseurl)
+        url = "{}/operations/transportpce-device-renderer:service-path".format(test_utils.RESTCONF_BASE_URL)
         data = {"renderer:input": {
             "renderer:service-name": "service_test",
             "renderer:wave-number": "7",
@@ -161,10 +97,9 @@ class TransportPCERendererTesting(unittest.TestCase):
                 {"renderer:node-id": "XPDRA01",
                  "renderer:src-tp": "XPDR1-CLIENT1",
                  "renderer:dest-tp": "XPDR1-NETWORK1"}]}}
-        headers = {'content-type': 'application/json'}
         response = requests.request(
             "POST", url, data=json.dumps(data),
-            headers=headers, auth=('admin', 'admin'))
+            headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
         self.assertEqual(response.status_code, requests.codes.ok)
         res = response.json()
         self.assertIn('Roadm-connection successfully created for nodes: ROADMA01', res["output"]["result"])
@@ -173,16 +108,22 @@ class TransportPCERendererTesting(unittest.TestCase):
         url = ("{}/config/network-topology:network-topology/topology/topology-netconf/"
                "node/ROADMA01/yang-ext:mount/org-openroadm-device:org-openroadm-device/"
                "interface/DEG1-TTP-TXRX-7"
-               .format(self.restconf_baseurl))
-        headers = {'content-type': 'application/json'}
+               .format(test_utils.RESTCONF_BASE_URL))
         response = requests.request(
-            "GET", url, headers=headers, auth=('admin', 'admin'))
+            "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
         self.assertEqual(response.status_code, requests.codes.ok)
         res = response.json()
-        self.assertDictContainsSubset({'name': 'DEG1-TTP-TXRX-7', 'administrative-state': 'inService',
-                                       'supporting-circuit-pack-name': '2/0',
-                                       'type': 'org-openroadm-interfaces:opticalChannel',
-                                       'supporting-port': 'L1'}, res['interface'][0])
+        # the following statement replaces self.assertDictContainsSubset deprecated in python 3.2
+        self.assertDictEqual(
+            dict({
+                'name': 'DEG1-TTP-TXRX-7',
+                'administrative-state': 'inService',
+                'supporting-circuit-pack-name': '2/0',
+                'type': 'org-openroadm-interfaces:opticalChannel',
+                'supporting-port': 'L1'
+            }, **res['interface'][0]),
+            res['interface'][0]
+        )
         self.assertDictEqual(
             {'wavelength-number': 7},
             res['interface'][0]['org-openroadm-optical-channel-interfaces:och'])
@@ -191,18 +132,22 @@ class TransportPCERendererTesting(unittest.TestCase):
         url = ("{}/config/network-topology:network-topology/topology/topology-netconf/"
                "node/ROADMA01/yang-ext:mount/org-openroadm-device:org-openroadm-device/"
                "interface/SRG1-PP7-TXRX-7"
-               .format(self.restconf_baseurl))
-        headers = {'content-type': 'application/json'}
+               .format(test_utils.RESTCONF_BASE_URL))
         response = requests.request(
-            "GET", url, headers=headers, auth=('admin', 'admin'))
+            "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
         self.assertEqual(response.status_code, requests.codes.ok)
         res = response.json()
-        self.assertDictContainsSubset(
-            {'name': 'SRG1-PP7-TXRX-7', 'administrative-state': 'inService',
-             'supporting-circuit-pack-name': '4/0',
-             'type': 'org-openroadm-interfaces:opticalChannel',
-             'supporting-port': 'C7'},
-            res['interface'][0])
+        # the following statement replaces self.assertDictContainsSubset deprecated in python 3.2
+        self.assertDictEqual(
+            dict({
+                'name': 'SRG1-PP7-TXRX-7',
+                'administrative-state': 'inService',
+                'supporting-circuit-pack-name': '4/0',
+                'type': 'org-openroadm-interfaces:opticalChannel',
+                'supporting-port': 'C7'
+            }, **res['interface'][0]),
+            res['interface'][0]
+        )
         self.assertDictEqual(
             {'wavelength-number': 7},
             res['interface'][0]['org-openroadm-optical-channel-interfaces:och'])
@@ -211,17 +156,20 @@ class TransportPCERendererTesting(unittest.TestCase):
         url = ("{}/config/network-topology:network-topology/topology/topology-netconf/"
                "node/ROADMA01/yang-ext:mount/org-openroadm-device:org-openroadm-device/"
                "roadm-connections/SRG1-PP7-TXRX-DEG1-TTP-TXRX-7"
-               .format(self.restconf_baseurl))
-        headers = {'content-type': 'application/json'}
+               .format(test_utils.RESTCONF_BASE_URL))
         response = requests.request(
-            "GET", url, headers=headers, auth=('admin', 'admin'))
+            "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
         self.assertEqual(response.status_code, requests.codes.ok)
         res = response.json()
-        self.assertDictContainsSubset(
-            {'connection-number': 'SRG1-PP7-TXRX-DEG1-TTP-TXRX-7',
-             'wavelength-number': 7,
-             'opticalControlMode': 'off'},
-            res['roadm-connections'][0])
+        # the following statement replaces self.assertDictContainsSubset deprecated in python 3.2
+        self.assertDictEqual(
+            dict({
+                'connection-number': 'SRG1-PP7-TXRX-DEG1-TTP-TXRX-7',
+                'wavelength-number': 7,
+                'opticalControlMode': 'off'
+            }, **res['roadm-connections'][0]),
+            res['roadm-connections'][0]
+        )
         self.assertDictEqual(
             {'src-if': 'SRG1-PP7-TXRX-7'},
             res['roadm-connections'][0]['source'])
@@ -233,18 +181,22 @@ class TransportPCERendererTesting(unittest.TestCase):
         url = ("{}/config/network-topology:network-topology/topology/topology-netconf/"
                "node/XPDRA01/yang-ext:mount/org-openroadm-device:org-openroadm-device/"
                "interface/XPDR1-NETWORK1-7"
-               .format(self.restconf_baseurl))
-        headers = {'content-type': 'application/json'}
+               .format(test_utils.RESTCONF_BASE_URL))
         response = requests.request(
-            "GET", url, headers=headers, auth=('admin', 'admin'))
+            "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
         self.assertEqual(response.status_code, requests.codes.ok)
         res = response.json()
-        self.assertDictContainsSubset(
-            {'name': 'XPDR1-NETWORK1-7', 'administrative-state': 'inService',
-             'supporting-circuit-pack-name': '1/0/1-PLUG-NET',
-             'type': 'org-openroadm-interfaces:opticalChannel',
-             'supporting-port': '1'},
-            res['interface'][0])
+        # the following statement replaces self.assertDictContainsSubset deprecated in python 3.2
+        self.assertDictEqual(
+            dict({
+                'name': 'XPDR1-NETWORK1-7',
+                'administrative-state': 'inService',
+                'supporting-circuit-pack-name': '1/0/1-PLUG-NET',
+                'type': 'org-openroadm-interfaces:opticalChannel',
+                'supporting-port': '1'
+            }, **res['interface'][0]),
+            res['interface'][0]
+        )
         self.assertDictEqual(
             {u'rate': u'org-openroadm-optical-channel-interfaces:R100G',
              u'transmit-power': -5,
@@ -256,19 +208,23 @@ class TransportPCERendererTesting(unittest.TestCase):
         url = ("{}/config/network-topology:network-topology/topology/topology-netconf/"
                "node/XPDRA01/yang-ext:mount/org-openroadm-device:org-openroadm-device/"
                "interface/XPDR1-NETWORK1-OTU"
-               .format(self.restconf_baseurl))
-        headers = {'content-type': 'application/json'}
+               .format(test_utils.RESTCONF_BASE_URL))
         response = requests.request(
-            "GET", url, headers=headers, auth=('admin', 'admin'))
+            "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
         self.assertEqual(response.status_code, requests.codes.ok)
         res = response.json()
-        self.assertDictContainsSubset(
-            {'name': 'XPDR1-NETWORK1-OTU', 'administrative-state': 'inService',
-             'supporting-circuit-pack-name': '1/0/1-PLUG-NET',
-             'type': 'org-openroadm-interfaces:otnOtu',
-             'supporting-port': '1',
-             'supporting-interface': 'XPDR1-NETWORK1-7'},
-            res['interface'][0])
+        # the following statement replaces self.assertDictContainsSubset deprecated in python 3.2
+        self.assertDictEqual(
+            dict({
+                'name': 'XPDR1-NETWORK1-OTU',
+                'administrative-state': 'inService',
+                'supporting-circuit-pack-name': '1/0/1-PLUG-NET',
+                'type': 'org-openroadm-interfaces:otnOtu',
+                'supporting-port': '1',
+                'supporting-interface': 'XPDR1-NETWORK1-7'
+            }, **res['interface'][0]),
+            res['interface'][0]
+        )
         self.assertDictEqual(
             {u'rate': u'org-openroadm-otn-otu-interfaces:OTU4',
              u'fec': u'scfec'},
@@ -278,23 +234,30 @@ class TransportPCERendererTesting(unittest.TestCase):
         url = ("{}/config/network-topology:network-topology/topology/topology-netconf/"
                "node/XPDRA01/yang-ext:mount/org-openroadm-device:org-openroadm-device/"
                "interface/XPDR1-NETWORK1-ODU"
-               .format(self.restconf_baseurl))
-        headers = {'content-type': 'application/json'}
+               .format(test_utils.RESTCONF_BASE_URL))
         response = requests.request(
-            "GET", url, headers=headers, auth=('admin', 'admin'))
+            "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
         self.assertEqual(response.status_code, requests.codes.ok)
         res = response.json()
-        self.assertDictContainsSubset(
-            {'name': 'XPDR1-NETWORK1-ODU', 'administrative-state': 'inService',
-             'supporting-circuit-pack-name': '1/0/1-PLUG-NET',
-             'type': 'org-openroadm-interfaces:otnOdu',
-             'supporting-port': '1',
-             'supporting-interface': 'XPDR1-NETWORK1-OTU'},
-            res['interface'][0])
-        self.assertDictContainsSubset(
-            {'rate': 'org-openroadm-otn-odu-interfaces:ODU4',
-             u'monitoring-mode': u'terminated'},
-            res['interface'][0]['org-openroadm-otn-odu-interfaces:odu'])
+        # the 2 following statements replace self.assertDictContainsSubset deprecated in python 3.2
+        self.assertDictEqual(
+            dict({
+                'name': 'XPDR1-NETWORK1-ODU',
+                'administrative-state': 'inService',
+                'supporting-circuit-pack-name': '1/0/1-PLUG-NET',
+                'type': 'org-openroadm-interfaces:otnOdu',
+                'supporting-port': '1',
+                'supporting-interface': 'XPDR1-NETWORK1-OTU'
+            }, **res['interface'][0]),
+            res['interface'][0]
+        )
+        self.assertDictEqual(
+            dict({
+                'rate': 'org-openroadm-otn-odu-interfaces:ODU4',
+                u'monitoring-mode': u'terminated'
+            }, **res['interface'][0]['org-openroadm-otn-odu-interfaces:odu']),
+            res['interface'][0]['org-openroadm-otn-odu-interfaces:odu']
+        )
         self.assertDictEqual({u'exp-payload-type': u'07', u'payload-type': u'07'},
                              res['interface'][0]['org-openroadm-otn-odu-interfaces:odu']['opu'])
 
@@ -302,18 +265,22 @@ class TransportPCERendererTesting(unittest.TestCase):
         url = ("{}/config/network-topology:network-topology/topology/topology-netconf/"
                "node/XPDRA01/yang-ext:mount/org-openroadm-device:org-openroadm-device/"
                "interface/XPDR1-CLIENT1-ETHERNET"
-               .format(self.restconf_baseurl))
-        headers = {'content-type': 'application/json'}
+               .format(test_utils.RESTCONF_BASE_URL))
         response = requests.request(
-            "GET", url, headers=headers, auth=('admin', 'admin'))
+            "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
         self.assertEqual(response.status_code, requests.codes.ok)
         res = response.json()
-        self.assertDictContainsSubset(
-            {'name': 'XPDR1-CLIENT1-ETHERNET', 'administrative-state': 'inService',
-             'supporting-circuit-pack-name': '1/0/C1-PLUG-CLIENT',
-             'type': 'org-openroadm-interfaces:ethernetCsmacd',
-             'supporting-port': 'C1'},
-            res['interface'][0])
+        # the following statement replaces self.assertDictContainsSubset deprecated in python 3.2
+        self.assertDictEqual(
+            dict({
+                'name': 'XPDR1-CLIENT1-ETHERNET',
+                'administrative-state': 'inService',
+                'supporting-circuit-pack-name': '1/0/C1-PLUG-CLIENT',
+                'type': 'org-openroadm-interfaces:ethernetCsmacd',
+                'supporting-port': 'C1'
+            }, **res['interface'][0]),
+            res['interface'][0]
+        )
         self.assertDictEqual(
             {'speed': 100000,
              'mtu': 9000,
@@ -326,16 +293,15 @@ class TransportPCERendererTesting(unittest.TestCase):
         url = ("{}/config/network-topology:network-topology/topology/topology-netconf/"
                "node/XPDRA01/yang-ext:mount/org-openroadm-device:org-openroadm-device/"
                "circuit-packs/1%2F0%2F1-PLUG-NET"
-               .format(self.restconf_baseurl))
-        headers = {'content-type': 'application/json'}
+               .format(test_utils.RESTCONF_BASE_URL))
         response = requests.request(
-            "GET", url, headers=headers, auth=('admin', 'admin'))
+            "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
         self.assertEqual(response.status_code, requests.codes.ok)
         res = response.json()
         self.assertIn('not-reserved-inuse', res['circuit-packs'][0]["equipment-state"])
 
     def test_14_service_path_delete(self):
-        url = "{}/operations/transportpce-device-renderer:service-path".format(self.restconf_baseurl)
+        url = "{}/operations/transportpce-device-renderer:service-path".format(test_utils.RESTCONF_BASE_URL)
         data = {"renderer:input": {
             "renderer:service-name": "service_test",
             "renderer:wave-number": "7",
@@ -347,10 +313,9 @@ class TransportPCERendererTesting(unittest.TestCase):
                 {"renderer:node-id": "XPDRA01",
                  "renderer:src-tp": "XPDR1-CLIENT1",
                  "renderer:dest-tp": "XPDR1-NETWORK1"}]}}
-        headers = {'content-type': 'application/json'}
         response = requests.request(
             "POST", url, data=json.dumps(data),
-            headers=headers, auth=('admin', 'admin'))
+            headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
         self.assertEqual(response.status_code, requests.codes.ok)
         self.assertEqual(response.json(), {
             'output': {'result': 'Request processed', 'success': True}})
@@ -359,10 +324,9 @@ class TransportPCERendererTesting(unittest.TestCase):
         url = ("{}/config/network-topology:network-topology/topology/topology-netconf/"
                "node/ROADMA01/yang-ext:mount/org-openroadm-device:org-openroadm-device/"
                "interface/DEG1-TTP-TXRX-7"
-               .format(self.restconf_baseurl))
-        headers = {'content-type': 'application/json'}
+               .format(test_utils.RESTCONF_BASE_URL))
         response = requests.request(
-            "GET", url, headers=headers, auth=('admin', 'admin'))
+            "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
         self.assertEqual(response.status_code, requests.codes.not_found)
         res = response.json()
         self.assertIn(
@@ -374,10 +338,9 @@ class TransportPCERendererTesting(unittest.TestCase):
         url = ("{}/config/network-topology:network-topology/topology/topology-netconf/"
                "node/ROADMA01/yang-ext:mount/org-openroadm-device:org-openroadm-device/"
                "interface/SRG1-PP7-TXRX-7"
-               .format(self.restconf_baseurl))
-        headers = {'content-type': 'application/json'}
+               .format(test_utils.RESTCONF_BASE_URL))
         response = requests.request(
-            "GET", url, headers=headers, auth=('admin', 'admin'))
+            "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
         self.assertEqual(response.status_code, requests.codes.not_found)
         res = response.json()
         self.assertIn(
@@ -389,10 +352,9 @@ class TransportPCERendererTesting(unittest.TestCase):
         url = ("{}/config/network-topology:network-topology/topology/topology-netconf/"
                "node/ROADMA01/yang-ext:mount/org-openroadm-device:org-openroadm-device/"
                "roadm-connections/SRG1-PP7-TXRX-DEG1-TTP-TXRX-7"
-               .format(self.restconf_baseurl))
-        headers = {'content-type': 'application/json'}
+               .format(test_utils.RESTCONF_BASE_URL))
         response = requests.request(
-            "GET", url, headers=headers, auth=('admin', 'admin'))
+            "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
         self.assertEqual(response.status_code, requests.codes.not_found)
         res = response.json()
         self.assertIn(
@@ -404,10 +366,9 @@ class TransportPCERendererTesting(unittest.TestCase):
         url = ("{}/config/network-topology:network-topology/topology/topology-netconf/"
                "node/XPDRA01/yang-ext:mount/org-openroadm-device:org-openroadm-device/"
                "interface/XPDR1-NETWORK1-7"
-               .format(self.restconf_baseurl))
-        headers = {'content-type': 'application/json'}
+               .format(test_utils.RESTCONF_BASE_URL))
         response = requests.request(
-            "GET", url, headers=headers, auth=('admin', 'admin'))
+            "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
         self.assertEqual(response.status_code, requests.codes.not_found)
         res = response.json()
         self.assertIn(
@@ -419,10 +380,9 @@ class TransportPCERendererTesting(unittest.TestCase):
         url = ("{}/config/network-topology:network-topology/topology/topology-netconf/"
                "node/XPDRA01/yang-ext:mount/org-openroadm-device:org-openroadm-device/"
                "interface/XPDR1-NETWORK1-OTU"
-               .format(self.restconf_baseurl))
-        headers = {'content-type': 'application/json'}
+               .format(test_utils.RESTCONF_BASE_URL))
         response = requests.request(
-            "GET", url, headers=headers, auth=('admin', 'admin'))
+            "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
         self.assertEqual(response.status_code, requests.codes.not_found)
         res = response.json()
         self.assertIn(
@@ -434,10 +394,9 @@ class TransportPCERendererTesting(unittest.TestCase):
         url = ("{}/config/network-topology:network-topology/topology/topology-netconf/"
                "node/XPDRA01/yang-ext:mount/org-openroadm-device:org-openroadm-device/"
                "interface/XPDR1-NETWORK1-ODU"
-               .format(self.restconf_baseurl))
-        headers = {'content-type': 'application/json'}
+               .format(test_utils.RESTCONF_BASE_URL))
         response = requests.request(
-            "GET", url, headers=headers, auth=('admin', 'admin'))
+            "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
         self.assertEqual(response.status_code, requests.codes.not_found)
         res = response.json()
         self.assertIn(
@@ -449,10 +408,9 @@ class TransportPCERendererTesting(unittest.TestCase):
         url = ("{}/config/network-topology:network-topology/topology/topology-netconf/"
                "node/XPDRA01/yang-ext:mount/org-openroadm-device:org-openroadm-device/"
                "interface/XPDR1-CLIENT1-ETHERNET"
-               .format(self.restconf_baseurl))
-        headers = {'content-type': 'application/json'}
+               .format(test_utils.RESTCONF_BASE_URL))
         response = requests.request(
-            "GET", url, headers=headers, auth=('admin', 'admin'))
+            "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
         self.assertEqual(response.status_code, requests.codes.not_found)
         res = response.json()
         self.assertIn(
@@ -464,35 +422,20 @@ class TransportPCERendererTesting(unittest.TestCase):
         url = ("{}/config/network-topology:network-topology/topology/topology-netconf/"
                "node/XPDRA01/yang-ext:mount/org-openroadm-device:org-openroadm-device/"
                "circuit-packs/1%2F0%2F1-PLUG-NET"
-               .format(self.restconf_baseurl))
-        headers = {'content-type': 'application/json'}
+               .format(test_utils.RESTCONF_BASE_URL))
         response = requests.request(
-            "GET", url, headers=headers, auth=('admin', 'admin'))
+            "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
         self.assertEqual(response.status_code, requests.codes.ok)
         res = response.json()
         self.assertEqual('not-reserved-available', res["circuit-packs"][0]['equipment-state'])
 
     def test_23_rdm_device_disconnected(self):
-        url = ("{}/config/network-topology:"
-               "network-topology/topology/topology-netconf/node/ROADMA01"
-               .format(self.restconf_baseurl))
-        headers = {'content-type': 'application/json'}
-        response = requests.request(
-            "DELETE", url, headers=headers,
-            auth=('admin', 'admin'))
-        self.assertEqual(response.status_code, requests.codes.ok)
-        time.sleep(20)
+        response = test_utils.unmount_device("ROADMA01")
+        self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200)
 
     def test_24_xpdr_device_disconnected(self):
-        url = ("{}/config/network-topology:"
-               "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'))
-        self.assertEqual(response.status_code, requests.codes.ok)
-        time.sleep(20)
+        response = test_utils.unmount_device("XPDRA01")
+        self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200)
 
 
 if __name__ == "__main__":