Fix remaining pylint warnings apart fixme & dup
[transportpce.git] / tests / transportpce_tests / 1.2.1 / test02_topo_portmapping.py
1 #!/usr/bin/env python
2
3 ##############################################################################
4 # Copyright (c) 2017 Orange, Inc. and others.  All rights reserved.
5 #
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Apache License, Version 2.0
8 # which accompanies this distribution, and is available at
9 # http://www.apache.org/licenses/LICENSE-2.0
10 ##############################################################################
11
12 # pylint: disable=no-member
13 # pylint: disable=too-many-public-methods
14 # a pylint false positive due to unittest
15 # pylint: disable=no-self-use
16
17 import time
18 import unittest
19 import requests
20 # pylint: disable=wrong-import-order
21 import sys
22 sys.path.append('transportpce_tests/common/')
23 # pylint: disable=wrong-import-position
24 # pylint: disable=import-error
25 import test_utils_rfc8040  # nopep8
26
27
28 class TransportPCEtesting(unittest.TestCase):
29
30     processes = None
31     NODE_VERSION = '1.2.1'
32
33     @classmethod
34     def setUpClass(cls):
35         cls.processes = test_utils_rfc8040.start_tpce()
36         cls.processes = test_utils_rfc8040.start_sims([('xpdra', cls.NODE_VERSION), ('roadma', cls.NODE_VERSION)])
37
38     @classmethod
39     def tearDownClass(cls):
40         # pylint: disable=not-an-iterable
41         for process in cls.processes:
42             test_utils_rfc8040.shutdown_process(process)
43         print("all processes killed")
44
45     def setUp(self):
46         time.sleep(10)
47
48     # Connect the ROADMA
49     def test_01_connect_rdm(self):
50         response = test_utils_rfc8040.mount_device("ROADMA01", ('roadma', self.NODE_VERSION))
51         self.assertEqual(response.status_code, requests.codes.created, test_utils_rfc8040.CODE_SHOULD_BE_201)
52
53     # Verify the termination points of the ROADMA
54     def test_02_compare_Openroadm_topology_portmapping_rdm(self):
55         responseTopo = test_utils_rfc8040.get_request(test_utils_rfc8040.URL_CONFIG_ORDM_TOPO)
56         resTopo = responseTopo.json()
57         for val in resTopo['ietf-network:network'][0]['node']:
58             nodeId = val['node-id']
59             nodeMapId = nodeId.split("-")[0]
60             response = test_utils_rfc8040.get_portmapping_node_info(nodeMapId)
61             self.assertEqual(response['status_code'], requests.codes.ok)
62             for val2 in val['ietf-network-topology:termination-point']:
63                 tpId = val2['tp-id']
64                 if (not "CP" in tpId) and (not "CTP" in tpId):
65                     response2 = test_utils_rfc8040.portmapping_request(nodeMapId, tpId)
66                     self.assertEqual(response2['status_code'], requests.codes.ok)
67
68     # Disconnect the ROADMA
69     def test_03_disconnect_rdm(self):
70         response = test_utils_rfc8040.unmount_device("ROADMA01")
71         self.assertIn(response.status_code, (requests.codes.ok, requests.codes.no_content))
72
73 #     #Connect the XPDRA
74     def test_04_connect_xpdr(self):
75         response = test_utils_rfc8040.mount_device("XPDRA01", ('xpdra', self.NODE_VERSION))
76         self.assertEqual(response.status_code, requests.codes.created, test_utils_rfc8040.CODE_SHOULD_BE_201)
77
78 #     #Verify the termination points related to XPDR
79     def test_05_compare_Openroadm_topology_portmapping_xpdr(self):
80         self.test_02_compare_Openroadm_topology_portmapping_rdm()
81
82     # Disconnect the XPDRA
83     def test_06_disconnect_device(self):
84         response = test_utils_rfc8040.unmount_device("XPDRA01")
85         self.assertIn(response.status_code, (requests.codes.ok, requests.codes.no_content))
86
87
88 if __name__ == "__main__":
89     # logging.basicConfig(filename='./transportpce_tests/log/response.log',filemode='w',level=logging.DEBUG)
90     #logging.debug('I am there')
91     unittest.main(verbosity=2)