From 34e0396a49784d0a117087559eab80c258a7bf31 Mon Sep 17 00:00:00 2001 From: "guillaume.lambert" Date: Fri, 29 Oct 2021 11:51:54 +0200 Subject: [PATCH] Enforce autopep8 via pre-commit Signed-off-by: guillaume.lambert Change-Id: Ia0021347c46488ecc2a922f4e370ca5ad4edafd9 --- .pre-commit-config.yaml | 7 +++ docs/conf.py | 1 - .../1.2.1/test01_portmapping.py | 1 - .../2.2.1/test13_tapi_full_multi_layer.py | 46 +++++++++---------- .../2.2.1/test14_otn_switch_end2end.py | 9 ++-- tests/transportpce_tests/common/test_utils.py | 12 ++++- 6 files changed, 44 insertions(+), 32 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bc040d936..baa871ba7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -19,3 +19,10 @@ repos: - id: remove-tabs stages: [commit] exclude: '^(.git/|docs/make.bat|docs/Makefile|ordmodels/)' + + - repo: https://github.com/pre-commit/mirrors-autopep8 + rev: v1.5.7 + hooks: + - id: autopep8 + args: ['--in-place', '--max-line-length=120'] + diff --git a/docs/conf.py b/docs/conf.py index ed284d509..0eae08853 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -18,4 +18,3 @@ linkcheck_ignore = [ 'https://0201.nccdn.net/1_2/000/000/134/c50/Open-ROADM-MSA-release-2-Device-White-paper-v1-1.pdf' ] linkcheck_timeout = 300 - diff --git a/tests/transportpce_tests/1.2.1/test01_portmapping.py b/tests/transportpce_tests/1.2.1/test01_portmapping.py index 47c8a56ac..f9a1b51f7 100644 --- a/tests/transportpce_tests/1.2.1/test01_portmapping.py +++ b/tests/transportpce_tests/1.2.1/test01_portmapping.py @@ -243,6 +243,5 @@ class TransportPCEPortMappingTesting(unittest.TestCase): res['errors']['error']) - if __name__ == "__main__": unittest.main(verbosity=2) diff --git a/tests/transportpce_tests/2.2.1/test13_tapi_full_multi_layer.py b/tests/transportpce_tests/2.2.1/test13_tapi_full_multi_layer.py index b25d96c48..4901b377c 100644 --- a/tests/transportpce_tests/2.2.1/test13_tapi_full_multi_layer.py +++ b/tests/transportpce_tests/2.2.1/test13_tapi_full_multi_layer.py @@ -34,7 +34,7 @@ class TransportPCEtesting(unittest.TestCase): "layer-protocol-name": "PHOTONIC_MEDIA", "service-interface-point": { "service-interface-point-uuid": "b1a0d883-32b8-3b0b-93d6-7ed074f6f107" - }, + }, "administrative-state": "UNLOCKED", "operational-state": "ENABLED", "direction": "BIDIRECTIONAL", @@ -52,7 +52,7 @@ class TransportPCEtesting(unittest.TestCase): "layer-protocol-name": "PHOTONIC_MEDIA", "service-interface-point": { "service-interface-point-uuid": "d1d6305e-179b-346f-b02d-8260aebe1ce8" - }, + }, "administrative-state": "UNLOCKED", "operational-state": "ENABLED", "direction": "BIDIRECTIONAL", @@ -257,11 +257,11 @@ class TransportPCEtesting(unittest.TestCase): print("photonic media service uuid : {}".format(res['output']['service']['uuid'])) input_dict_1 = {'administrative-state': 'LOCKED', - 'lifecycle-state': 'PLANNED', - 'operational-state': 'DISABLED', - 'service-type': 'POINT_TO_POINT_CONNECTIVITY', - 'service-layer': 'PHOTONIC_MEDIA', - 'connectivity-direction': 'BIDIRECTIONAL' + 'lifecycle-state': 'PLANNED', + 'operational-state': 'DISABLED', + 'service-type': 'POINT_TO_POINT_CONNECTIVITY', + 'service-layer': 'PHOTONIC_MEDIA', + 'connectivity-direction': 'BIDIRECTIONAL' } input_dict_2 = {'value-name': 'OpenROADM node id', 'value': 'SPDR-SC1-XPDR1'} @@ -278,7 +278,7 @@ class TransportPCEtesting(unittest.TestCase): def test_16_get_service_PhotonicMedia(self): response = test_utils.get_service_list_request( - "services/"+ str(service_pm_uuid)) + "services/" + str(service_pm_uuid)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual( @@ -308,11 +308,11 @@ class TransportPCEtesting(unittest.TestCase): print("odu service uuid : {}".format(res['output']['service']['uuid'])) input_dict_1 = {'administrative-state': 'LOCKED', - 'lifecycle-state': 'PLANNED', - 'operational-state': 'DISABLED', - 'service-type': 'POINT_TO_POINT_CONNECTIVITY', - 'service-layer': 'ODU', - 'connectivity-direction': 'BIDIRECTIONAL' + 'lifecycle-state': 'PLANNED', + 'operational-state': 'DISABLED', + 'service-type': 'POINT_TO_POINT_CONNECTIVITY', + 'service-layer': 'ODU', + 'connectivity-direction': 'BIDIRECTIONAL' } input_dict_2 = {'value-name': 'OpenROADM node id', 'value': 'SPDR-SC1-XPDR1'} @@ -329,7 +329,7 @@ class TransportPCEtesting(unittest.TestCase): def test_18_get_service_ODU(self): response = test_utils.get_service_list_request( - "services/"+ str(service_odu_uuid)) + "services/" + str(service_odu_uuid)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual( @@ -360,11 +360,11 @@ class TransportPCEtesting(unittest.TestCase): print("dsr service uuid : {}".format(res['output']['service']['uuid'])) input_dict_1 = {'administrative-state': 'LOCKED', - 'lifecycle-state': 'PLANNED', - 'operational-state': 'DISABLED', - 'service-type': 'POINT_TO_POINT_CONNECTIVITY', - 'service-layer': 'DSR', - 'connectivity-direction': 'BIDIRECTIONAL' + 'lifecycle-state': 'PLANNED', + 'operational-state': 'DISABLED', + 'service-type': 'POINT_TO_POINT_CONNECTIVITY', + 'service-layer': 'DSR', + 'connectivity-direction': 'BIDIRECTIONAL' } input_dict_2 = {'value-name': 'OpenROADM node id', 'value': 'SPDR-SC1-XPDR1'} @@ -384,7 +384,7 @@ class TransportPCEtesting(unittest.TestCase): def test_20_get_service_DSR(self): response = test_utils.get_service_list_request( - "services/"+ str(service_dsr_uuid)) + "services/" + str(service_dsr_uuid)) self.assertEqual(response.status_code, requests.codes.ok) res = response.json() self.assertEqual( @@ -423,9 +423,9 @@ class TransportPCEtesting(unittest.TestCase): time.sleep(2) def test_22_delete_connectivity_service_DSR(self): - response = test_utils.tapi_delete_connectivity_request(service_dsr_uuid) - self.assertEqual(response.status_code, requests.codes.no_content) - time.sleep(self.WAITING) + response = test_utils.tapi_delete_connectivity_request(service_dsr_uuid) + self.assertEqual(response.status_code, requests.codes.no_content) + time.sleep(self.WAITING) def test_23_delete_connectivity_service_ODU(self): response = test_utils.tapi_delete_connectivity_request(service_odu_uuid) diff --git a/tests/transportpce_tests/2.2.1/test14_otn_switch_end2end.py b/tests/transportpce_tests/2.2.1/test14_otn_switch_end2end.py index 110111e3e..d66e72641 100644 --- a/tests/transportpce_tests/2.2.1/test14_otn_switch_end2end.py +++ b/tests/transportpce_tests/2.2.1/test14_otn_switch_end2end.py @@ -1111,9 +1111,9 @@ class TransportPCEtesting(unittest.TestCase): self.assertEqual(nb_links, 4) for link in res['network'][0]['ietf-network-topology:link']: self.assertEqual( - link['org-openroadm-otn-network-topology:available-bandwidth'], 0) + link['org-openroadm-otn-network-topology:available-bandwidth'], 0) self.assertEqual( - link['org-openroadm-otn-network-topology:used-bandwidth'], 100000) + link['org-openroadm-otn-network-topology:used-bandwidth'], 100000) def test_60_delete_service_100GE_ABC(self): response = test_utils.service_delete_request("service-100GE-ABC") @@ -1283,7 +1283,7 @@ class TransportPCEtesting(unittest.TestCase): for link in links: if ((link["org-openroadm-common-network:link-type"] == "XPONDER-OUTPUT" or link["org-openroadm-common-network:link-type"] == "XPONDER-INPUT") - and ('SPDR-SB1' in link['link-id'] or 'ROADM-B1' in link['link-id'])): + and ('SPDR-SB1' in link['link-id'] or 'ROADM-B1' in link['link-id'])): link_name = link["link-id"] response = test_utils.delete_request(url+link_name) self.assertEqual(response.status_code, requests.codes.ok) @@ -1306,7 +1306,7 @@ class TransportPCEtesting(unittest.TestCase): links = res['network'][0]['ietf-network-topology:link'] for link in links: if (link["org-openroadm-common-network:link-type"] == "ROADM-TO-ROADM" - and 'ROADM-B1' in link['link-id']): + and 'ROADM-B1' in link['link-id']): link_name = link["link-id"] response = test_utils.delete_request(url+link_name) self.assertEqual(response.status_code, requests.codes.ok) @@ -1430,7 +1430,6 @@ class TransportPCEtesting(unittest.TestCase): self.test_50_check_interface_ODU4_NETWORK_spdra() self.test_51_check_ODU4_connection_spdra() - def test_88_check_configuration_spdrc(self): self.test_52_check_interface_100GE_CLIENT_spdrc() self.test_53_check_interface_ODU4_CLIENT_spdrc() diff --git a/tests/transportpce_tests/common/test_utils.py b/tests/transportpce_tests/common/test_utils.py index 46bf27a67..d5118149b 100644 --- a/tests/transportpce_tests/common/test_utils.py +++ b/tests/transportpce_tests/common/test_utils.py @@ -393,6 +393,7 @@ def service_delete_request(servicename: str, "tail-retention": "no"}}} return post_request(URL_SERV_DELETE, attr) + def service_path_request(operation: str, servicename: str, wavenumber: str, nodes, centerfreq: str, slotwidth: int, minfreq: float, maxfreq: float, lowerslotnumber: int, higherslotnumber: int): @@ -446,20 +447,24 @@ def path_computation_request(requestid: str, servicename: str, serviceaend, serv attr.update(other_attr) return post_request(URL_PATH_COMPUTATION_REQUEST, {"input": attr}) + def tapi_create_connectivity_request(topologyidorname): return post_request(URL_TAPI_CREATE_CONNECTIVITY, topologyidorname) + def tapi_delete_connectivity_request(serviceidorname): attr = { "input": { "service-id-or-name": serviceidorname}} - return post_request(URL_TAPI_DELETE_CONNECTIVITY , attr) + return post_request(URL_TAPI_DELETE_CONNECTIVITY, attr) + def tapi_get_topology_details_request(topologyidorname): attr = { "input": { "topology-id-or-name": topologyidorname}} - return post_request(URL_TAPI_TOPOLOGY_DETAILS , attr) + return post_request(URL_TAPI_TOPOLOGY_DETAILS, attr) + def tapi_get_node_details_request(topologyidorname, nodeidorname): attr = { @@ -468,12 +473,15 @@ def tapi_get_node_details_request(topologyidorname, nodeidorname): "node-id-or-name": nodeidorname}} return post_request(URL_TAPI_NODE_DETAILS, attr) + def tapi_get_sip_details_request(): return post_request(URL_TAPI_SIP_LIST, "") + def tapi_get_service_list_request(): return post_request(URL_TAPI_SERVICE_LIST, "") + def shutdown_process(process): if process is not None: for child in psutil.Process(process.pid).children(): -- 2.36.6