X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=tests%2Ftransportpce_tests%2F1.2.1%2Ftest_end2end.py;h=03481040ad13caad828f1a112ac823ee3234be94;hb=c8bd98e0844257ae2e40e01d54546a40596df26d;hp=b5c7711fae5df4f066d2850db850a9e4887a88b5;hpb=e9cca3f8a24859b4cfadf65db6ac9a59c9a9755a;p=transportpce.git diff --git a/tests/transportpce_tests/1.2.1/test_end2end.py b/tests/transportpce_tests/1.2.1/test_end2end.py index b5c7711fa..03481040a 100644 --- a/tests/transportpce_tests/1.2.1/test_end2end.py +++ b/tests/transportpce_tests/1.2.1/test_end2end.py @@ -16,175 +16,64 @@ import unittest import psutil import requests -import test_utils +from common import test_utils class TransportPCEFulltesting(unittest.TestCase): - headers = {'content-type': 'application/json'} - odl_process = None - honeynode_process1 = None - honeynode_process2 = None - honeynode_process3 = None - honeynode_process4 = None - restconf_baseurl = "http://localhost:8181/restconf" + WAITING = 20 # nominal value is 300 - # 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_full_honeynode() - time.sleep(20) - - print("starting honeynode3...") - cls.honeynode_process3 = test_utils.start_roadmc_full_honeynode() - time.sleep(20) - - print("starting honeynode4...") - cls.honeynode_process4 = test_utils.start_xpdrc_honeynode() - time.sleep(20) - print("all honeynodes started") - - print("starting opendaylight...") - cls.odl_process = test_utils.start_tpce() - time.sleep(80) - print("opendaylight started") + cls.processes = test_utils.start_tpce() + cls.processes = test_utils.start_sims(['xpdra', 'roadma-full', 'roadmc-full', 'xpdrc']) @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 child in psutil.Process(cls.honeynode_process3.pid).children(): - child.send_signal(signal.SIGINT) - child.wait() - cls.honeynode_process3.send_signal(signal.SIGINT) - cls.honeynode_process3.wait() - for child in psutil.Process(cls.honeynode_process4.pid).children(): - child.send_signal(signal.SIGINT) - child.wait() - cls.honeynode_process4.send_signal(signal.SIGINT) - cls.honeynode_process4.wait() + for process in cls.processes: + test_utils.shutdown_process(process) print("all processes killed") def setUp(self): # instruction executed before each test method print("execution of {}".format(self.id().split(".")[-1])) - # END_IGNORE_XTESTING - # connect netconf devices def test_01_connect_xpdrA(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_02_connect_xpdrC(self): - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/XPDRC01" - .format(self.restconf_baseurl)) - data = {"node": [{ - "node-id": "XPDRC01", - "netconf-node-topology:username": "admin", - "netconf-node-topology:password": "admin", - "netconf-node-topology:host": "127.0.0.1", - "netconf-node-topology:port": "17834", - "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("XPDRC01", 'xpdrc') + self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201) def test_03_connect_rdmA(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": "17821", - "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-full') + self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201) def test_04_connect_rdmC(self): - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/ROADMC01" - .format(self.restconf_baseurl)) - data = {"node": [{ - "node-id": "ROADMC01", - "netconf-node-topology:username": "admin", - "netconf-node-topology:password": "admin", - "netconf-node-topology:host": "127.0.0.1", - "netconf-node-topology:port": "17823", - "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("ROADMC01", 'roadmc-full') + self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201) def test_05_connect_xprdA_N1_to_roadmA_PP1(self): url = "{}/operations/transportpce-networkutils:init-xpdr-rdm-links".\ - format(self.restconf_baseurl) + format(test_utils.RESTCONF_BASE_URL) data = { - "networkutils:input": { - "networkutils:links-input": { - "networkutils:xpdr-node": "XPDRA01", - "networkutils:xpdr-num": "1", - "networkutils:network-num": "1", - "networkutils:rdm-node": "ROADMA01", - "networkutils:srg-num": "1", - "networkutils:termination-point-num": "SRG1-PP1-TXRX" + "networkutils:input": { + "networkutils:links-input": { + "networkutils:xpdr-node": "XPDRA01", + "networkutils:xpdr-num": "1", + "networkutils:network-num": "1", + "networkutils:rdm-node": "ROADMA01", + "networkutils:srg-num": "1", + "networkutils:termination-point-num": "SRG1-PP1-TXRX" + } } - } } - 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('Xponder Roadm Link created successfully', @@ -193,23 +82,22 @@ class TransportPCEFulltesting(unittest.TestCase): def test_06_connect_roadmA_PP1_to_xpdrA_N1(self): url = "{}/operations/transportpce-networkutils:init-rdm-xpdr-links".\ - format(self.restconf_baseurl) + format(test_utils.RESTCONF_BASE_URL) data = { - "networkutils:input": { - "networkutils:links-input": { - "networkutils:xpdr-node": "XPDRA01", - "networkutils:xpdr-num": "1", - "networkutils:network-num": "1", - "networkutils:rdm-node": "ROADMA01", - "networkutils:srg-num": "1", - "networkutils:termination-point-num": "SRG1-PP1-TXRX" + "networkutils:input": { + "networkutils:links-input": { + "networkutils:xpdr-node": "XPDRA01", + "networkutils:xpdr-num": "1", + "networkutils:network-num": "1", + "networkutils:rdm-node": "ROADMA01", + "networkutils:srg-num": "1", + "networkutils:termination-point-num": "SRG1-PP1-TXRX" + } } - } } - 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 Xponder links created successfully', @@ -218,23 +106,22 @@ class TransportPCEFulltesting(unittest.TestCase): def test_07_connect_xprdC_N1_to_roadmC_PP1(self): url = "{}/operations/transportpce-networkutils:init-xpdr-rdm-links".\ - format(self.restconf_baseurl) + format(test_utils.RESTCONF_BASE_URL) data = { - "networkutils:input": { - "networkutils:links-input": { - "networkutils:xpdr-node": "XPDRC01", - "networkutils:xpdr-num": "1", - "networkutils:network-num": "1", - "networkutils:rdm-node": "ROADMC01", - "networkutils:srg-num": "1", - "networkutils:termination-point-num": "SRG1-PP1-TXRX" + "networkutils:input": { + "networkutils:links-input": { + "networkutils:xpdr-node": "XPDRC01", + "networkutils:xpdr-num": "1", + "networkutils:network-num": "1", + "networkutils:rdm-node": "ROADMC01", + "networkutils:srg-num": "1", + "networkutils:termination-point-num": "SRG1-PP1-TXRX" + } } - } } - 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('Xponder Roadm Link created successfully', @@ -243,23 +130,22 @@ class TransportPCEFulltesting(unittest.TestCase): def test_08_connect_roadmC_PP1_to_xpdrC_N1(self): url = "{}/operations/transportpce-networkutils:init-rdm-xpdr-links".\ - format(self.restconf_baseurl) + format(test_utils.RESTCONF_BASE_URL) data = { - "networkutils:input": { - "networkutils:links-input": { - "networkutils:xpdr-node": "XPDRC01", - "networkutils:xpdr-num": "1", - "networkutils:network-num": "1", - "networkutils:rdm-node": "ROADMC01", - "networkutils:srg-num": "1", - "networkutils:termination-point-num": "SRG1-PP1-TXRX" + "networkutils:input": { + "networkutils:links-input": { + "networkutils:xpdr-node": "XPDRC01", + "networkutils:xpdr-num": "1", + "networkutils:network-num": "1", + "networkutils:rdm-node": "ROADMC01", + "networkutils:srg-num": "1", + "networkutils:termination-point-num": "SRG1-PP1-TXRX" + } } - } } - 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 Xponder links created successfully', @@ -269,12 +155,12 @@ class TransportPCEFulltesting(unittest.TestCase): def test_09_add_omsAttributes_ROADMA_ROADMC(self): # Config ROADMA-ROADMC oms-attributes url = ( - "{}/config/ietf-network:" - "networks/network/openroadm-topology/ietf-network-topology:" - "link/ROADMA01-DEG1-DEG1-TTP-TXRXtoROADMC01-DEG2-DEG2-TTP-TXRX/" - "org-openroadm-network-topology:" - "OMS-attributes/span" - .format(self.restconf_baseurl)) + "{}/config/ietf-network:" + "networks/network/openroadm-topology/ietf-network-topology:" + "link/ROADMA01-DEG1-DEG1-TTP-TXRXtoROADMC01-DEG2-DEG2-TTP-TXRX/" + "org-openroadm-network-topology:" + "OMS-attributes/span" + .format(test_utils.RESTCONF_BASE_URL)) data = {"span": { "clfi": "fiber1", "auto-spanloss": "true", @@ -286,42 +172,40 @@ class TransportPCEFulltesting(unittest.TestCase): "fiber-type": "smf", "SRLG-length": 100000, "pmd": 0.5}]}} - headers = {'content-type': 'application/json'} response = requests.request( - "PUT", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) + "PUT", url, data=json.dumps(data), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.created) def test_10_add_omsAttributes_ROADMC_ROADMA(self): # Config ROADMC-ROADMA oms-attributes url = ( - "{}/config/ietf-network:" - "networks/network/openroadm-topology/ietf-network-topology:" - "link/ROADMC01-DEG2-DEG2-TTP-TXRXtoROADMA01-DEG1-DEG1-TTP-TXRX/" - "org-openroadm-network-topology:" - "OMS-attributes/span" - .format(self.restconf_baseurl)) + "{}/config/ietf-network:" + "networks/network/openroadm-topology/ietf-network-topology:" + "link/ROADMC01-DEG2-DEG2-TTP-TXRXtoROADMA01-DEG1-DEG1-TTP-TXRX/" + "org-openroadm-network-topology:" + "OMS-attributes/span" + .format(test_utils.RESTCONF_BASE_URL)) data = {"span": { - "clfi": "fiber1", - "auto-spanloss": "true", - "spanloss-base": 11.4, - "spanloss-current": 12, - "engineered-spanloss": 12.2, - "link-concatenation": [{ - "SRLG-Id": 0, - "fiber-type": "smf", - "SRLG-length": 100000, - "pmd": 0.5}]}} - headers = {'content-type': 'application/json'} + "clfi": "fiber1", + "auto-spanloss": "true", + "spanloss-base": 11.4, + "spanloss-current": 12, + "engineered-spanloss": 12.2, + "link-concatenation": [{ + "SRLG-Id": 0, + "fiber-type": "smf", + "SRLG-length": 100000, + "pmd": 0.5}]}} response = requests.request( - "PUT", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) + "PUT", url, data=json.dumps(data), headers=test_utils.TYPE_APPLICATION_JSON, + auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.created) # test service-create for Eth service from xpdr to xpdr def test_11_create_eth_service1(self): url = ("{}/operations/org-openroadm-service:service-create" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = { "input": { "sdnc-request-header": { @@ -420,25 +304,21 @@ class TransportPCEFulltesting(unittest.TestCase): "operator-contact": "pw1234" } } - headers = {'content-type': 'application/json', - "Accept": "application/json"} response = requests.request( - "POST", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) + "POST", url, data=json.dumps(data), 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('PCE calculation in progress', res['output']['configuration-response-common'][ - 'response-message']) + 'response-message']) time.sleep(self.WAITING) def test_12_get_eth_service1(self): url = ("{}/operational/org-openroadm-service:service-list/services/" - "service1".format(self.restconf_baseurl)) - headers = {'content-type': 'application/json', - "Accept": "application/json"} + "service1".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( @@ -459,18 +339,21 @@ class TransportPCEFulltesting(unittest.TestCase): "node/ROADMA01/yang-ext:" "mount/org-openroadm-device:org-openroadm-device/" "roadm-connections/SRG1-PP1-TXRX-DEG1-TTP-TXRX-1" - .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-PP1-TXRX-DEG1-TTP-TXRX-1', - 'wavelength-number': 1, - 'opticalControlMode': 'gainLoss', - 'target-output-power': -3.0}, - res['roadm-connections'][0]) + # the following statement replaces self.assertDictContainsSubset deprecated in python 3.2 + self.assertDictEqual( + dict({ + 'connection-number': 'SRG1-PP1-TXRX-DEG1-TTP-TXRX-1', + 'wavelength-number': 1, + 'opticalControlMode': 'gainLoss', + 'target-output-power': -3.0 + }, **res['roadm-connections'][0]), + res['roadm-connections'][0] + ) self.assertDictEqual( {'src-if': 'SRG1-PP1-TXRX-1'}, res['roadm-connections'][0]['source']) @@ -486,18 +369,21 @@ class TransportPCEFulltesting(unittest.TestCase): "node/ROADMC01/yang-ext:mount/org-openroadm-device:" "org-openroadm-device/" "roadm-connections/SRG1-PP1-TXRX-DEG2-TTP-TXRX-1" - .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-PP1-TXRX-DEG2-TTP-TXRX-1', - 'wavelength-number': 1, - 'opticalControlMode': 'gainLoss', - 'target-output-power': 2.0}, - res['roadm-connections'][0]) + # the following statement replaces self.assertDictContainsSubset deprecated in python 3.2 + self.assertDictEqual( + dict({ + 'connection-number': 'SRG1-PP1-TXRX-DEG2-TTP-TXRX-1', + 'wavelength-number': 1, + 'opticalControlMode': 'gainLoss', + 'target-output-power': 2.0 + }, **res['roadm-connections'][0]), + res['roadm-connections'][0] + ) self.assertDictEqual( {'src-if': 'SRG1-PP1-TXRX-1'}, res['roadm-connections'][0]['source']) @@ -510,9 +396,9 @@ class TransportPCEFulltesting(unittest.TestCase): url1 = ( "{}/config/ietf-network:" "networks/network/openroadm-topology/node/XPDRA01-XPDR1" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url1, auth=('admin', 'admin')) + "GET", url1, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() liste_tp = res['node'][0]['ietf-network-topology:termination-point'] @@ -538,9 +424,9 @@ class TransportPCEFulltesting(unittest.TestCase): url1 = ( "{}/config/ietf-network:" "networks/network/openroadm-topology/node/ROADMA01-SRG1" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url1, auth=('admin', 'admin')) + "GET", url1, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertNotIn({u'index': 1}, @@ -562,9 +448,9 @@ class TransportPCEFulltesting(unittest.TestCase): url1 = ( "{}/config/ietf-network:" "networks/network/openroadm-topology/node/ROADMA01-DEG1" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url1, auth=('admin', 'admin')) + "GET", url1, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertNotIn({u'index': 1}, @@ -588,7 +474,7 @@ class TransportPCEFulltesting(unittest.TestCase): def test_18_connect_xprdA_N2_to_roadmA_PP2(self): url = "{}/operations/transportpce-networkutils:init-xpdr-rdm-links".\ - format(self.restconf_baseurl) + format(test_utils.RESTCONF_BASE_URL) data = { "networkutils:input": { "networkutils:links-input": { @@ -601,10 +487,9 @@ class TransportPCEFulltesting(unittest.TestCase): } } } - 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('Xponder Roadm Link created successfully', @@ -613,7 +498,7 @@ class TransportPCEFulltesting(unittest.TestCase): def test_19_connect_roadmA_PP2_to_xpdrA_N2(self): url = "{}/operations/transportpce-networkutils:init-rdm-xpdr-links".\ - format(self.restconf_baseurl) + format(test_utils.RESTCONF_BASE_URL) data = { "networkutils:input": { "networkutils:links-input": { @@ -626,10 +511,9 @@ class TransportPCEFulltesting(unittest.TestCase): } } } - 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 Xponder links created successfully', @@ -638,7 +522,7 @@ class TransportPCEFulltesting(unittest.TestCase): def test_20_connect_xprdC_N2_to_roadmC_PP2(self): url = "{}/operations/transportpce-networkutils:init-xpdr-rdm-links".\ - format(self.restconf_baseurl) + format(test_utils.RESTCONF_BASE_URL) data = { "networkutils:input": { "networkutils:links-input": { @@ -651,10 +535,9 @@ class TransportPCEFulltesting(unittest.TestCase): } } } - 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('Xponder Roadm Link created successfully', @@ -663,7 +546,7 @@ class TransportPCEFulltesting(unittest.TestCase): def test_21_connect_roadmC_PP2_to_xpdrC_N2(self): url = "{}/operations/transportpce-networkutils:init-rdm-xpdr-links".\ - format(self.restconf_baseurl) + format(test_utils.RESTCONF_BASE_URL) data = { "networkutils:input": { "networkutils:links-input": { @@ -676,10 +559,9 @@ class TransportPCEFulltesting(unittest.TestCase): } } } - 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 Xponder links created successfully', @@ -688,7 +570,7 @@ class TransportPCEFulltesting(unittest.TestCase): def test_22_create_eth_service2(self): url = ("{}/operations/org-openroadm-service:service-create" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = { "input": { "sdnc-request-header": { @@ -787,11 +669,9 @@ class TransportPCEFulltesting(unittest.TestCase): "operator-contact": "pw1234" } } - headers = {'content-type': 'application/json', - "Accept": "application/json"} response = requests.request( - "POST", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) + "POST", url, data=json.dumps(data), 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('PCE calculation in progress', @@ -802,11 +682,9 @@ class TransportPCEFulltesting(unittest.TestCase): def test_23_get_eth_service2(self): url = ("{}/operational/org-openroadm-service:" "service-list/services/service2" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json', - "Accept": "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( @@ -827,17 +705,20 @@ class TransportPCEFulltesting(unittest.TestCase): "node/ROADMA01/yang-ext:" "mount/org-openroadm-device:org-openroadm-device/" "roadm-connections/DEG1-TTP-TXRX-SRG1-PP2-TXRX-2" - .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': 'DEG1-TTP-TXRX-SRG1-PP2-TXRX-2', - 'wavelength-number': 2, - 'opticalControlMode': 'power'}, - res['roadm-connections'][0]) + # the following statement replaces self.assertDictContainsSubset deprecated in python 3.2 + self.assertDictEqual( + dict({ + 'connection-number': 'DEG1-TTP-TXRX-SRG1-PP2-TXRX-2', + 'wavelength-number': 2, + 'opticalControlMode': 'power' + }, **res['roadm-connections'][0]), + res['roadm-connections'][0] + ) self.assertDictEqual( {'src-if': 'DEG1-TTP-TXRX-2'}, res['roadm-connections'][0]['source']) @@ -849,9 +730,9 @@ class TransportPCEFulltesting(unittest.TestCase): url1 = ( "{}/config/ietf-network:" "networks/network/openroadm-topology/node/XPDRA01-XPDR1" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url1, auth=('admin', 'admin')) + "GET", url1, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() liste_tp = res['node'][0]['ietf-network-topology:termination-point'] @@ -877,9 +758,9 @@ class TransportPCEFulltesting(unittest.TestCase): url1 = ( "{}/config/ietf-network:" "networks/network/openroadm-topology/node/ROADMA01-SRG1" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url1, auth=('admin', 'admin')) + "GET", url1, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertNotIn({u'index': 1}, res['node'][0][ @@ -915,9 +796,9 @@ class TransportPCEFulltesting(unittest.TestCase): url1 = ( "{}/config/ietf-network:" "networks/network/openroadm-topology/node/ROADMA01-DEG1" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url1, auth=('admin', 'admin')) + "GET", url1, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertNotIn({u'index': 1}, res['node'][0][ @@ -947,7 +828,7 @@ class TransportPCEFulltesting(unittest.TestCase): # creation service test on a non-available resource def test_28_create_eth_service3(self): url = ("{}/operations/org-openroadm-service:service-create" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = { "input": { "sdnc-request-header": { @@ -1046,11 +927,9 @@ class TransportPCEFulltesting(unittest.TestCase): "operator-contact": "pw1234" } } - headers = {'content-type': 'application/json', - "Accept": "application/json"} response = requests.request( - "POST", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) + "POST", url, data=json.dumps(data), 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('PCE calculation in progress', @@ -1065,7 +944,7 @@ class TransportPCEFulltesting(unittest.TestCase): def test_29_delete_eth_service3(self): url = ("{}/operations/org-openroadm-service:service-delete" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = {"input": { "sdnc-request-header": { "request-id": "e3028bae-a90f-4ddd-a83f-cf224eba0e58", @@ -1080,10 +959,9 @@ class TransportPCEFulltesting(unittest.TestCase): } } } - headers = {'content-type': 'application/json'} response = requests.request( - "POST", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) + "POST", url, data=json.dumps(data), 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('Service \'service3\' does not exist in datastore', @@ -1095,7 +973,7 @@ class TransportPCEFulltesting(unittest.TestCase): def test_30_delete_eth_service1(self): url = ("{}/operations/org-openroadm-service:service-delete" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = {"input": { "sdnc-request-header": { "request-id": "e3028bae-a90f-4ddd-a83f-cf224eba0e58", @@ -1110,10 +988,9 @@ class TransportPCEFulltesting(unittest.TestCase): } } } - headers = {'content-type': 'application/json'} response = requests.request( - "POST", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) + "POST", url, data=json.dumps(data), 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('Renderer service delete in progress', @@ -1123,7 +1000,7 @@ class TransportPCEFulltesting(unittest.TestCase): def test_31_delete_eth_service2(self): url = ("{}/operations/org-openroadm-service:service-delete" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = {"input": { "sdnc-request-header": { "request-id": "e3028bae-a90f-4ddd-a83f-cf224eba0e58", @@ -1138,10 +1015,9 @@ class TransportPCEFulltesting(unittest.TestCase): } } } - headers = {'content-type': 'application/json'} response = requests.request( - "POST", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) + "POST", url, data=json.dumps(data), 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('Renderer service delete in progress', @@ -1155,9 +1031,9 @@ class TransportPCEFulltesting(unittest.TestCase): "network-topology/topology/topology-netconf/" "node/ROADMA01/yang-ext:" "mount/org-openroadm-device:org-openroadm-device/" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url, auth=('admin', 'admin')) + "GET", url, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) res = response.json() self.assertEqual(response.status_code, requests.codes.ok) self.assertNotIn('roadm-connections', @@ -1168,9 +1044,9 @@ class TransportPCEFulltesting(unittest.TestCase): url1 = ( "{}/config/ietf-network:" "networks/network/openroadm-topology/node/XPDRA01-XPDR1" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url1, auth=('admin', 'admin')) + "GET", url1, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() liste_tp = res['node'][0]['ietf-network-topology:termination-point'] @@ -1196,9 +1072,9 @@ class TransportPCEFulltesting(unittest.TestCase): url1 = ( "{}/config/ietf-network:" "networks/network/openroadm-topology/node/ROADMA01-SRG1" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url1, auth=('admin', 'admin')) + "GET", url1, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn({u'index': 1}, res['node'][0][ @@ -1222,9 +1098,9 @@ class TransportPCEFulltesting(unittest.TestCase): url1 = ( "{}/config/ietf-network:" "networks/network/openroadm-topology/node/ROADMA01-DEG1" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) response = requests.request( - "GET", url1, auth=('admin', 'admin')) + "GET", url1, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertIn({u'index': 1}, res['node'][0][ @@ -1246,7 +1122,7 @@ class TransportPCEFulltesting(unittest.TestCase): # test service-create for Optical Channel (OC) service from srg-pp to srg-pp def test_36_create_oc_service1(self): url = ("{}/operations/org-openroadm-service:service-create" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = { "input": { "sdnc-request-header": { @@ -1345,11 +1221,9 @@ class TransportPCEFulltesting(unittest.TestCase): "operator-contact": "pw1234" } } - headers = {'content-type': 'application/json', - "Accept": "application/json"} response = requests.request( - "POST", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) + "POST", url, data=json.dumps(data), 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('PCE calculation in progress', @@ -1360,11 +1234,9 @@ class TransportPCEFulltesting(unittest.TestCase): def test_37_get_oc_service1(self): url = ("{}/operational/org-openroadm-service:" "service-list/services/service1" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json', - "Accept": "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( @@ -1385,18 +1257,21 @@ class TransportPCEFulltesting(unittest.TestCase): "node/ROADMA01/yang-ext:" "mount/org-openroadm-device:org-openroadm-device/" "roadm-connections/SRG1-PP1-TXRX-DEG1-TTP-TXRX-1" - .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-PP1-TXRX-DEG1-TTP-TXRX-1', - 'wavelength-number': 1, - 'opticalControlMode': 'gainLoss', - 'target-output-power': -3.0}, - res['roadm-connections'][0]) + # the following statement replaces self.assertDictContainsSubset deprecated in python 3.2 + self.assertDictEqual( + dict({ + 'connection-number': 'SRG1-PP1-TXRX-DEG1-TTP-TXRX-1', + 'wavelength-number': 1, + 'opticalControlMode': 'gainLoss', + 'target-output-power': -3.0 + }, **res['roadm-connections'][0]), + res['roadm-connections'][0] + ) self.assertDictEqual( {'src-if': 'SRG1-PP1-TXRX-1'}, res['roadm-connections'][0]['source']) @@ -1412,18 +1287,21 @@ class TransportPCEFulltesting(unittest.TestCase): "node/ROADMC01/yang-ext:mount/org-openroadm-device:" "org-openroadm-device/" "roadm-connections/SRG1-PP1-TXRX-DEG2-TTP-TXRX-1" - .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-PP1-TXRX-DEG2-TTP-TXRX-1', - 'wavelength-number': 1, - 'opticalControlMode': 'gainLoss', - 'target-output-power': 2.0}, - res['roadm-connections'][0]) + # the following statement replaces self.assertDictContainsSubset deprecated in python 3.2 + self.assertDictEqual( + dict({ + 'connection-number': 'SRG1-PP1-TXRX-DEG2-TTP-TXRX-1', + 'wavelength-number': 1, + 'opticalControlMode': 'gainLoss', + 'target-output-power': 2.0 + }, **res['roadm-connections'][0]), + res['roadm-connections'][0] + ) self.assertDictEqual( {'src-if': 'SRG1-PP1-TXRX-1'}, res['roadm-connections'][0]['source']) @@ -1434,7 +1312,7 @@ class TransportPCEFulltesting(unittest.TestCase): def test_40_create_oc_service2(self): url = ("{}/operations/org-openroadm-service:service-create" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = { "input": { "sdnc-request-header": { @@ -1533,11 +1411,9 @@ class TransportPCEFulltesting(unittest.TestCase): "operator-contact": "pw1234" } } - headers = {'content-type': 'application/json', - "Accept": "application/json"} response = requests.request( - "POST", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) + "POST", url, data=json.dumps(data), 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('PCE calculation in progress', @@ -1548,11 +1424,9 @@ class TransportPCEFulltesting(unittest.TestCase): def test_41_get_oc_service2(self): url = ("{}/operational/org-openroadm-service:" "service-list/services/service2" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json', - "Accept": "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( @@ -1573,18 +1447,21 @@ class TransportPCEFulltesting(unittest.TestCase): "node/ROADMA01/yang-ext:mount/org-openroadm-device:" "org-openroadm-device/" "roadm-connections/SRG1-PP2-TXRX-DEG1-TTP-TXRX-2" - .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-PP2-TXRX-DEG1-TTP-TXRX-2', - 'wavelength-number': 2, - 'opticalControlMode': 'gainLoss', - 'target-output-power': -3.0}, - res['roadm-connections'][0]) + # the following statement replaces self.assertDictContainsSubset deprecated in python 3.2 + self.assertDictEqual( + dict({ + 'connection-number': 'SRG1-PP2-TXRX-DEG1-TTP-TXRX-2', + 'wavelength-number': 2, + 'opticalControlMode': 'gainLoss', + 'target-output-power': -3.0 + }, **res['roadm-connections'][0]), + res['roadm-connections'][0] + ) self.assertDictEqual( {'src-if': 'SRG1-PP2-TXRX-2'}, res['roadm-connections'][0]['source']) @@ -1600,7 +1477,7 @@ class TransportPCEFulltesting(unittest.TestCase): def test_44_delete_oc_service1(self): url = ("{}/operations/org-openroadm-service:service-delete" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = {"input": { "sdnc-request-header": { "request-id": "e3028bae-a90f-4ddd-a83f-cf224eba0e58", @@ -1615,10 +1492,9 @@ class TransportPCEFulltesting(unittest.TestCase): } } } - headers = {'content-type': 'application/json'} response = requests.request( - "POST", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) + "POST", url, data=json.dumps(data), 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('Renderer service delete in progress', @@ -1628,7 +1504,7 @@ class TransportPCEFulltesting(unittest.TestCase): def test_45_delete_oc_service2(self): url = ("{}/operations/org-openroadm-service:service-delete" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = {"input": { "sdnc-request-header": { "request-id": "e3028bae-a90f-4ddd-a83f-cf224eba0e58", @@ -1643,10 +1519,9 @@ class TransportPCEFulltesting(unittest.TestCase): } } } - headers = {'content-type': 'application/json'} response = requests.request( - "POST", url, data=json.dumps(data), headers=headers, - auth=('admin', 'admin')) + "POST", url, data=json.dumps(data), 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('Renderer service delete in progress', @@ -1657,11 +1532,9 @@ class TransportPCEFulltesting(unittest.TestCase): def test_46_get_no_oc_services(self): print("start test") url = ("{}/operational/org-openroadm-service:service-list" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json', - "Accept": "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( @@ -1681,11 +1554,9 @@ class TransportPCEFulltesting(unittest.TestCase): "network-topology/topology/topology-netconf" "/node/ROADMA01/yang-ext:mount/org-openroadm-device:" "org-openroadm-device/" - .format(self.restconf_baseurl)) - headers = {'content-type': 'application/json', - "Accept": "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.assertNotIn(['roadm-connections'][0], res['org-openroadm-device']) @@ -1710,11 +1581,11 @@ class TransportPCEFulltesting(unittest.TestCase): def test_50_loop_create_oc_service(self): url = ("{}/operational/org-openroadm-service:" "service-list/services/service1" - .format(self.restconf_baseurl)) - response = requests.request("GET", url, auth=('admin', 'admin')) + .format(test_utils.RESTCONF_BASE_URL)) + response = requests.request("GET", url, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD)) if response.status_code != 404: url = ("{}/operations/org-openroadm-service:service-delete" - .format(self.restconf_baseurl)) + .format(test_utils.RESTCONF_BASE_URL)) data = {"input": { "sdnc-request-header": { "request-id": "e3028bae-a90f-4ddd-a83f-cf224eba0e58", @@ -1729,10 +1600,9 @@ class TransportPCEFulltesting(unittest.TestCase): } } } - headers = {'content-type': 'application/json'} 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) ) time.sleep(5) @@ -1748,48 +1618,20 @@ class TransportPCEFulltesting(unittest.TestCase): self.test_44_delete_oc_service1() def test_51_disconnect_XPDRA(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(10) + response = test_utils.unmount_device("XPDRA01") + self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200) def test_52_disconnect_XPDRC(self): - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/XPDRC01" - .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(10) + response = test_utils.unmount_device("XPDRC01") + self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200) def test_53_disconnect_ROADMA(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(10) + response = test_utils.unmount_device("ROADMA01") + self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200) def test_54_disconnect_ROADMC(self): - url = ("{}/config/network-topology:" - "network-topology/topology/topology-netconf/node/ROADMC01" - .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(10) + response = test_utils.unmount_device("ROADMC01") + self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200) if __name__ == "__main__":