fix funcional test issue when list in dict 90/101290/4
authorGilles Thouenon <gilles.thouenon@orange.com>
Wed, 25 May 2022 13:27:31 +0000 (15:27 +0200)
committermanuedelf <emmanuelle.delfour@orange.com>
Wed, 15 Jun 2022 10:05:20 +0000 (12:05 +0200)
Adapt few functional test to be able to compare dictionaries containing
list, where order of items inside the list is taken into acount.

JIRA: TRNSPRTPCE-666
Signed-off-by: Gilles Thouenon <gilles.thouenon@orange.com>
Change-Id: I0fb6f235348583f04e7777f06698ed430c3320f2

tests/transportpce_tests/2.2.1/test01_portmapping.py
tests/transportpce_tests/7.1/test02_otn_renderer.py

index 3e56063ec99819cff719fcf30adcc5cb64926e4d..a77584ddd0bbb59213f33a45216f5eb8b22a67b5 100644 (file)
@@ -249,19 +249,21 @@ class TransportPCEPortMappingTesting(unittest.TestCase):
     def test_22_spdr_portmapping_XPDR1_CLIENT1(self):
         response = test_utils_rfc8040.portmapping_request("SPDR-SA1", "XPDR1-CLIENT1")
         self.assertEqual(response['status_code'], requests.codes.ok)
-        self.assertIn(
-            {"logical-connection-point": "XPDR1-CLIENT1",
-             "supporting-circuit-pack-name": "CP1-SFP1",
-             "supported-interface-capability": ["org-openroadm-port-types:if-10GE-ODU2e",
-                                                "org-openroadm-port-types:if-10GE-ODU2"],
-             "supporting-port": "CP1-SFP1-P1",
-             "lcp-hash-val": "FqlcrxV7p30=",
-             "port-direction": "bidirectional",
-             "port-admin-state": "InService",
-             "xponder-type": "mpdr",
-             "port-qual": "xpdr-client",
-             "port-oper-state": "InService"},
-            response['mapping'])
+        expected_subset_response = {
+            "logical-connection-point": "XPDR1-CLIENT1",
+            "supporting-circuit-pack-name": "CP1-SFP1",
+            "supporting-port": "CP1-SFP1-P1",
+            "lcp-hash-val": "FqlcrxV7p30=",
+            "port-direction": "bidirectional",
+            "port-admin-state": "InService",
+            "xponder-type": "mpdr",
+            "port-qual": "xpdr-client",
+            "port-oper-state": "InService"}
+        expected_sorted_list = ["org-openroadm-port-types:if-10GE-ODU2",
+                                "org-openroadm-port-types:if-10GE-ODU2e"]
+        subset = {k: v for k, v in response['mapping'][0].items() if k in expected_subset_response}
+        self.assertDictEqual(subset, expected_subset_response)
+        self.assertEqual(sorted(response['mapping'][0]['supported-interface-capability']), expected_sorted_list)
 
     def test_23_spdr_portmapping_XPDR1_NETWORK1(self):
         response = test_utils_rfc8040.portmapping_request("SPDR-SA1", "XPDR1-NETWORK1")
@@ -282,19 +284,21 @@ class TransportPCEPortMappingTesting(unittest.TestCase):
     def test_24_spdr_portmapping_XPDR2_CLIENT2(self):
         response = test_utils_rfc8040.portmapping_request("SPDR-SA1", "XPDR2-CLIENT2")
         self.assertEqual(response['status_code'], requests.codes.ok)
-        self.assertIn(
-            {'logical-connection-point': 'XPDR2-CLIENT2',
-             'supporting-port': 'CP2-QSFP2-P1',
-             'lcp-hash-val': 'AN/WSSRXne3t',
-             'port-direction': 'bidirectional',
-             'xponder-type': 'switch',
-             'port-qual': 'switch-client',
-             'supporting-circuit-pack-name': 'CP2-QSFP2',
-             'port-admin-state': 'InService',
-             'port-oper-state': 'InService',
-             'supported-interface-capability': ['org-openroadm-port-types:if-100GE',
-                                                'org-openroadm-port-types:if-100GE-ODU4']},
-            response['mapping'])
+        expected_subset_response = {
+            'logical-connection-point': 'XPDR2-CLIENT2',
+            'supporting-port': 'CP2-QSFP2-P1',
+            'lcp-hash-val': 'AN/WSSRXne3t',
+            'port-direction': 'bidirectional',
+            'xponder-type': 'switch',
+            'port-qual': 'switch-client',
+            'supporting-circuit-pack-name': 'CP2-QSFP2',
+            'port-admin-state': 'InService',
+            'port-oper-state': 'InService'}
+        expected_sorted_list = ['org-openroadm-port-types:if-100GE',
+                                'org-openroadm-port-types:if-100GE-ODU4']
+        subset = {k: v for k, v in response['mapping'][0].items() if k in expected_subset_response}
+        self.assertDictEqual(subset, expected_subset_response)
+        self.assertEqual(sorted(response['mapping'][0]['supported-interface-capability']), expected_sorted_list)
 
     def test_25_spdr_portmapping_XPDR2_NETWORK2(self):
         response = test_utils_rfc8040.portmapping_request("SPDR-SA1", "XPDR2-NETWORK2")
index e5e8ed4c2e5bc45b4535795d23b76e190c50b05e..c4a0ecdb4b17bd3d2d7436c6c66b96b96d221129 100644 (file)
@@ -453,12 +453,14 @@ 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")
@@ -675,12 +677,14 @@ 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")