Fix 7.1 functional tests RFC8040 uncompatibilities
[transportpce.git] / tests / transportpce_tests / 7.1 / test02_otn_renderer.py
index 5ca29f374da94767d533484e6b0c5692b7e53d9b..58a25fa8ba580daf7e150c7bae032ca25ecc7d4d 100644 (file)
@@ -91,7 +91,7 @@ class TransportPCE400GPortMappingTesting(unittest.TestCase):
             response['output']['node-interface'])
 
     def test_03_get_portmapping_network1(self):
-        response = test_utils_rfc8040.portmapping_request("XPDR-A2", "XPDR2-NETWORK1")
+        response = test_utils_rfc8040.get_portmapping_node_attr("XPDR-A2", "mapping", "XPDR2-NETWORK1")
         self.assertEqual(response['status_code'], requests.codes.ok)
         self.NETWORK2_CHECK_DICT["supporting-otucn"] = "XPDR2-NETWORK1-OTUC2"
         self.assertIn(
@@ -182,7 +182,7 @@ class TransportPCE400GPortMappingTesting(unittest.TestCase):
              'odu-interface-id': ['XPDR2-NETWORK1-ODUC2']}, response['output']['node-interface'])
 
     def test_08_get_portmapping_network1(self):
-        response = test_utils_rfc8040.portmapping_request("XPDR-A2", "XPDR2-NETWORK1")
+        response = test_utils_rfc8040.get_portmapping_node_attr("XPDR-A2", "mapping", "XPDR2-NETWORK1")
         self.assertEqual(response['status_code'], requests.codes.ok)
         self.NETWORK2_CHECK_DICT["supporting-oducn"] = "XPDR2-NETWORK1-ODUC2"
         self.assertIn(
@@ -235,12 +235,12 @@ class TransportPCE400GPortMappingTesting(unittest.TestCase):
         self.assertEqual(response['status_code'], requests.codes.ok)
         self.assertIn('Otn Service path was set up successfully for node :XPDR-A2', response['output']['result'])
         self.assertEqual('XPDR-A2', response['output']['node-interface'][0]['node-id'])
-        self.assertIn('XPDR2-CLIENT1-ODU4-service_Ethernet-x-XPDR2-NETWORK1-ODU4-service_Ethernet',
+        self.assertIn('XPDR2-CLIENT1-ODU4-x-XPDR2-NETWORK1-ODU4',
                       response['output']['node-interface'][0]['connection-id'])
         self.assertIn('XPDR2-CLIENT1-ETHERNET-100G', response['output']['node-interface'][0]['eth-interface-id'])
-        self.assertIn('XPDR2-NETWORK1-ODU4-service_Ethernet',
+        self.assertIn('XPDR2-NETWORK1-ODU4',
                       response['output']['node-interface'][0]['odu-interface-id'])
-        self.assertIn('XPDR2-CLIENT1-ODU4-service_Ethernet',
+        self.assertIn('XPDR2-CLIENT1-ODU4',
                       response['output']['node-interface'][0]['odu-interface-id'])
 
     def test_11_check_interface_100ge_client(self):
@@ -262,9 +262,9 @@ class TransportPCE400GPortMappingTesting(unittest.TestCase):
 
     def test_12_check_interface_odu4_client(self):
         response = test_utils_rfc8040.check_node_attribute_request(
-            "XPDR-A2", "interface", "XPDR2-CLIENT1-ODU4-service_Ethernet")
+            "XPDR-A2", "interface", "XPDR2-CLIENT1-ODU4")
         self.assertEqual(response['status_code'], requests.codes.ok)
-        input_dict_1 = {'name': 'XPDR2-CLIENT1-ODU4-service_Ethernet',
+        input_dict_1 = {'name': 'XPDR2-CLIENT1-ODU4',
                         'administrative-state': 'inService',
                         'supporting-circuit-pack-name': '1/2/1/1-PLUG-CLIENT',
                         'supporting-interface-list': 'XPDR2-CLIENT1-ETHERNET-100G',
@@ -286,9 +286,9 @@ class TransportPCE400GPortMappingTesting(unittest.TestCase):
 
     def test_13_check_interface_odu4_network(self):
         response = test_utils_rfc8040.check_node_attribute_request(
-            "XPDR-A2", "interface", "XPDR2-NETWORK1-ODU4-service_Ethernet")
+            "XPDR-A2", "interface", "XPDR2-NETWORK1-ODU4")
         self.assertEqual(response['status_code'], requests.codes.ok)
-        input_dict_1 = {'name': 'XPDR2-NETWORK1-ODU4-service_Ethernet',
+        input_dict_1 = {'name': 'XPDR2-NETWORK1-ODU4',
                         'administrative-state': 'inService',
                         'supporting-circuit-pack-name': '1/2/2-PLUG-NET',
                         'supporting-interface-list': 'XPDR2-NETWORK1-ODUC2',
@@ -317,19 +317,19 @@ class TransportPCE400GPortMappingTesting(unittest.TestCase):
     def test_14_check_odu_connection_xpdra2(self):
         response = test_utils_rfc8040.check_node_attribute_request(
             "XPDR-A2",
-            "odu-connection", "XPDR2-CLIENT1-ODU4-service_Ethernet-x-XPDR2-NETWORK1-ODU4-service_Ethernet")
+            "odu-connection", "XPDR2-CLIENT1-ODU4-x-XPDR2-NETWORK1-ODU4")
         self.assertEqual(response['status_code'], requests.codes.ok)
         input_dict_1 = {
             'connection-name':
-            'XPDR2-CLIENT1-ODU4-service_Ethernet-x-XPDR2-NETWORK1-ODU4-service_Ethernet',
+            'XPDR2-CLIENT1-ODU4-x-XPDR2-NETWORK1-ODU4',
             'direction': 'bidirectional'
         }
 
         self.assertDictEqual(dict(input_dict_1, **response['odu-connection'][0]),
                              response['odu-connection'][0])
-        self.assertDictEqual({'dst-if': 'XPDR2-NETWORK1-ODU4-service_Ethernet'},
+        self.assertDictEqual({'dst-if': 'XPDR2-NETWORK1-ODU4'},
                              response['odu-connection'][0]['destination'])
-        self.assertDictEqual({'src-if': 'XPDR2-CLIENT1-ODU4-service_Ethernet'},
+        self.assertDictEqual({'src-if': 'XPDR2-CLIENT1-ODU4'},
                              response['odu-connection'][0]['source'])
 
     # 1d) Delete Ethernet device interfaces
@@ -352,17 +352,17 @@ class TransportPCE400GPortMappingTesting(unittest.TestCase):
     def test_16_check_no_odu_connection(self):
         response = test_utils_rfc8040.check_node_attribute_request(
             "XPDR-A2",
-            "odu-connection", "XPDR2-CLIENT1-ODU4-service_Ethernet-x-XPDR2-NETWORK1-ODU4-service_Ethernet")
+            "odu-connection", "XPDR2-CLIENT1-ODU4-x-XPDR2-NETWORK1-ODU4")
         self.assertEqual(response['status_code'], requests.codes.conflict)
 
     def test_17_check_no_interface_odu_network(self):
         response = test_utils_rfc8040.check_node_attribute_request(
-            "XPDR-A2", "interface", "XPDR2-NETWORK1-ODU4-service_Ethernet")
+            "XPDR-A2", "interface", "XPDR2-NETWORK1-ODU4")
         self.assertEqual(response['status_code'], requests.codes.conflict)
 
     def test_18_check_no_interface_odu_client(self):
         response = test_utils_rfc8040.check_node_attribute_request(
-            "XPDR-A2", "interface", "XPDR2-CLIENT1-ODU4-service_Ethernet")
+            "XPDR-A2", "interface", "XPDR2-CLIENT1-ODU4")
         self.assertEqual(response['status_code'], requests.codes.conflict)
 
     def test_19_check_no_interface_100ge_client(self):
@@ -392,7 +392,7 @@ class TransportPCE400GPortMappingTesting(unittest.TestCase):
 
     # Check if port-mapping data is updated, where the supporting-oducn is deleted
     def test_21a_check_no_oduc2(self):
-        response = test_utils_rfc8040.portmapping_request("XPDR-A2", "XPDR2-NETWORK1")
+        response = test_utils_rfc8040.get_portmapping_node_attr("XPDR-A2", "mapping", "XPDR2-NETWORK1")
         self.assertRaises(KeyError, lambda: response["supporting-oducn"])
 
     # 1f) Delete OTUC2 device interfaces
@@ -418,20 +418,20 @@ class TransportPCE400GPortMappingTesting(unittest.TestCase):
         del self.NETWORK2_CHECK_DICT["supporting-otucn"]
 
     def test_23_check_no_interface_otuc2(self):
-        response = test_utils_rfc8040.check_node_attribute_request("XPDR-A1", "interface", "XPDR2-NETWORK1-OTUC2")
+        response = test_utils_rfc8040.check_node_attribute_request("XPDR-A2", "interface", "XPDR2-NETWORK1-OTUC2")
         self.assertEqual(response['status_code'], requests.codes.conflict)
 
     def test_24_check_no_interface_otsig(self):
         response = test_utils_rfc8040.check_node_attribute_request(
-            "XPDR-A1", "interface", "XPDR2-NETWORK1-OTSIGROUP-200G")
+            "XPDR-A2", "interface", "XPDR2-NETWORK1-OTSIGROUP-200G")
         self.assertEqual(response['status_code'], requests.codes.conflict)
 
     def test_25_check_no_interface_otsi(self):
-        response = test_utils_rfc8040.check_node_attribute_request("XPDR-A1", "interface", "XPDR2-NETWORK1-755:768")
+        response = test_utils_rfc8040.check_node_attribute_request("XPDR-A2", "interface", "XPDR2-NETWORK1-755:768")
         self.assertEqual(response['status_code'], requests.codes.conflict)
 
     def test_25a_check_no_otuc2(self):
-        response = test_utils_rfc8040.portmapping_request("XPDR-A2", "XPDR2-NETWORK1")
+        response = test_utils_rfc8040.get_portmapping_node_attr("XPDR-A2", "mapping", "XPDR2-NETWORK1")
         self.assertRaises(KeyError, lambda: response["supporting-otucn"])
 
     # 2a) create a OTUC3 device renderer
@@ -453,15 +453,17 @@ class TransportPCE400GPortMappingTesting(unittest.TestCase):
             })
         self.assertEqual(response['status_code'], requests.codes.ok)
         self.assertIn('Interfaces created successfully for nodes: ', response['output']['result'])
-        self.assertIn(
-            {'node-id': 'XPDR-A2',
-             'otu-interface-id': ['XPDR2-NETWORK1-OTUC3'],
-             'och-interface-id': ['XPDR2-NETWORK1-755:768',
-                                  'XPDR2-NETWORK1-OTSIGROUP-300G']},
-            response['output']['node-interface'])
+        expected_subset_response = {
+            'node-id': 'XPDR-A2',
+            'otu-interface-id': ['XPDR2-NETWORK1-OTUC3']}
+        expected_sorted_list = ['XPDR2-NETWORK1-755:768',
+                                'XPDR2-NETWORK1-OTSIGROUP-300G']
+        subset = {k: v for k, v in response['output']['node-interface'][0].items() if k in expected_subset_response}
+        self.assertDictEqual(subset, expected_subset_response)
+        self.assertEqual(sorted(response['output']['node-interface'][0]['och-interface-id']), expected_sorted_list)
 
     def test_27_get_portmapping_network1(self):
-        response = test_utils_rfc8040.portmapping_request("XPDR-A2", "XPDR2-NETWORK1")
+        response = test_utils_rfc8040.get_portmapping_node_attr("XPDR-A2", "mapping", "XPDR2-NETWORK1")
         self.assertEqual(response['status_code'], requests.codes.ok)
         self.NETWORK2_CHECK_DICT["supporting-otucn"] = "XPDR2-NETWORK1-OTUC3"
         self.assertIn(
@@ -553,7 +555,7 @@ class TransportPCE400GPortMappingTesting(unittest.TestCase):
              'odu-interface-id': ['XPDR2-NETWORK1-ODUC3']}, response['output']['node-interface'])
 
     def test_32_get_portmapping_network1(self):
-        response = test_utils_rfc8040.portmapping_request("XPDR-A2", "XPDR2-NETWORK1")
+        response = test_utils_rfc8040.get_portmapping_node_attr("XPDR-A2", "mapping", "XPDR2-NETWORK1")
         self.assertEqual(response['status_code'], requests.codes.ok)
         self.NETWORK2_CHECK_DICT["supporting-oducn"] = "XPDR2-NETWORK1-ODUC3"
         self.assertIn(
@@ -615,7 +617,7 @@ class TransportPCE400GPortMappingTesting(unittest.TestCase):
         self.assertEqual(response['status_code'], requests.codes.conflict)
 
     def test_35a_check_no_oduc3(self):
-        response = test_utils_rfc8040.portmapping_request("XPDR-A2", "XPDR2-NETWORK1")
+        response = test_utils_rfc8040.get_portmapping_node_attr("XPDR-A2", "mapping", "XPDR2-NETWORK1")
         self.assertRaises(KeyError, lambda: response["supporting-oducn"])
 
     # 2f) Delete OTUC3 device interfaces
@@ -641,19 +643,19 @@ class TransportPCE400GPortMappingTesting(unittest.TestCase):
 
     def test_37_check_no_interface_otuc3(self):
         response = test_utils_rfc8040.check_node_attribute_request("XPDR-A1", "interface", "XPDR2-NETWORK1-OTUC3")
-        self.assertEqual(response['status_code'], requests.codes.conflict)
+        self.assertIn(response['status_code'], (requests.codes.conflict, requests.codes.service_unavailable))
 
     def test_38_check_no_interface_otsig(self):
         response = test_utils_rfc8040.check_node_attribute_request(
             "XPDR-A1", "interface", "XPDR2-NETWORK1-OTSIGROUP-300G")
-        self.assertEqual(response['status_code'], requests.codes.conflict)
+        self.assertIn(response['status_code'], (requests.codes.conflict, requests.codes.service_unavailable))
 
     def test_39_check_no_interface_otsi(self):
         response = test_utils_rfc8040.check_node_attribute_request("XPDR-A1", "interface", "XPDR2-NETWORK1-755:768")
-        self.assertEqual(response['status_code'], requests.codes.conflict)
+        self.assertIn(response['status_code'], (requests.codes.conflict, requests.codes.service_unavailable))
 
     def test_39a_check_no_otuc3(self):
-        response = test_utils_rfc8040.portmapping_request("XPDR-A2", "XPDR2-NETWORK1")
+        response = test_utils_rfc8040.get_portmapping_node_attr("XPDR-A2", "mapping", "XPDR2-NETWORK1")
         self.assertRaises(KeyError, lambda: response["supporting-otucn"])
 
     # 3a) create a OTUC4 device renderer
@@ -675,15 +677,17 @@ class TransportPCE400GPortMappingTesting(unittest.TestCase):
             })
         self.assertEqual(response['status_code'], requests.codes.ok)
         self.assertIn('Interfaces created successfully for nodes: ', response['output']['result'])
-        self.assertIn(
-            {'node-id': 'XPDR-A2',
-             'otu-interface-id': ['XPDR2-NETWORK1-OTUC4'],
-             'och-interface-id': ['XPDR2-NETWORK1-755:768',
-                                  'XPDR2-NETWORK1-OTSIGROUP-400G']},
-            response['output']['node-interface'])
+        expected_subset_response = {
+            'node-id': 'XPDR-A2',
+            'otu-interface-id': ['XPDR2-NETWORK1-OTUC4']}
+        expected_sorted_list = ['XPDR2-NETWORK1-755:768',
+                                'XPDR2-NETWORK1-OTSIGROUP-400G']
+        subset = {k: v for k, v in response['output']['node-interface'][0].items() if k in expected_subset_response}
+        self.assertDictEqual(subset, expected_subset_response)
+        self.assertEqual(sorted(response['output']['node-interface'][0]['och-interface-id']), expected_sorted_list)
 
     def test_41_get_portmapping_network1(self):
-        response = test_utils_rfc8040.portmapping_request("XPDR-A2", "XPDR2-NETWORK1")
+        response = test_utils_rfc8040.get_portmapping_node_attr("XPDR-A2", "mapping", "XPDR2-NETWORK1")
         self.assertEqual(response['status_code'], requests.codes.ok)
         self.NETWORK2_CHECK_DICT["supporting-otucn"] = "XPDR2-NETWORK1-OTUC4"
         self.assertIn(
@@ -775,7 +779,7 @@ class TransportPCE400GPortMappingTesting(unittest.TestCase):
              'odu-interface-id': ['XPDR2-NETWORK1-ODUC4']}, response['output']['node-interface'])
 
     def test_46_get_portmapping_network1(self):
-        response = test_utils_rfc8040.portmapping_request("XPDR-A2", "XPDR2-NETWORK1")
+        response = test_utils_rfc8040.get_portmapping_node_attr("XPDR-A2", "mapping", "XPDR2-NETWORK1")
         self.assertEqual(response['status_code'], requests.codes.ok)
         self.NETWORK2_CHECK_DICT["supporting-oducn"] = "XPDR2-NETWORK1-ODUC4"
         self.assertIn(
@@ -837,7 +841,7 @@ class TransportPCE400GPortMappingTesting(unittest.TestCase):
         self.assertEqual(response['status_code'], requests.codes.conflict)
 
     def test_49a_check_no_oduc4(self):
-        response = test_utils_rfc8040.portmapping_request("XPDR-A2", "XPDR2-NETWORK1")
+        response = test_utils_rfc8040.get_portmapping_node_attr("XPDR-A2", "mapping", "XPDR2-NETWORK1")
         self.assertRaises(KeyError, lambda: response["supporting-oducn"])
 
     # 3f) Delete OTUC4 device interfaces
@@ -863,19 +867,19 @@ class TransportPCE400GPortMappingTesting(unittest.TestCase):
 
     def test_51_check_no_interface_otuc4(self):
         response = test_utils_rfc8040.check_node_attribute_request("XPDR-A1", "interface", "XPDR2-NETWORK1-OTUC4")
-        self.assertEqual(response['status_code'], requests.codes.conflict)
+        self.assertIn(response['status_code'], (requests.codes.conflict, requests.codes.service_unavailable))
 
     def test_52_check_no_interface_otsig(self):
         response = test_utils_rfc8040.check_node_attribute_request(
             "XPDR-A1", "interface", "XPDR2-NETWORK1-OTSIGROUP-400G")
-        self.assertEqual(response['status_code'], requests.codes.conflict)
+        self.assertIn(response['status_code'], (requests.codes.conflict, requests.codes.service_unavailable))
 
     def test_53_check_no_interface_otsi(self):
         response = test_utils_rfc8040.check_node_attribute_request("XPDR-A1", "interface", "XPDR2-NETWORK1-755:768")
-        self.assertEqual(response['status_code'], requests.codes.conflict)
+        self.assertIn(response['status_code'], (requests.codes.conflict, requests.codes.service_unavailable))
 
     def test_53a_check_no_otuc4(self):
-        response = test_utils_rfc8040.portmapping_request("XPDR-A2", "XPDR2-NETWORK1")
+        response = test_utils_rfc8040.get_portmapping_node_attr("XPDR-A2", "mapping", "XPDR2-NETWORK1")
         self.assertRaises(KeyError, lambda: response["supporting-otucn"])
 
     # Disconnect the XPDR
@@ -892,7 +896,7 @@ class TransportPCE400GPortMappingTesting(unittest.TestCase):
                          'Request could not be completed because the relevant data model content does not exist')
 
     def test_56_xpdr_device_not_connected(self):
-        response = test_utils_rfc8040.get_portmapping_node_info("XPDR-A2")
+        response = test_utils_rfc8040.get_portmapping_node_attr("XPDR-A2", "node-info", None)
         self.assertEqual(response['status_code'], requests.codes.conflict)
         self.assertIn(response['node-info']['error-type'], ('protocol', 'application'))
         self.assertEqual(response['node-info']['error-tag'], 'data-missing')