From 9efdf5d846987b5c05828f1b680402fc88a86e1e Mon Sep 17 00:00:00 2001 From: arista-hpandya Date: Thu, 5 Sep 2024 00:02:42 +0000 Subject: [PATCH] Fix linter errors --- pfc/main.py | 8 +- tests/multi_asic_pfc_test.py | 1 - tests/pfc_input/assert_show_output.py | 2 +- tests/pfc_input/pfc_test_vectors.py | 111 +++++++++++++------------- 4 files changed, 63 insertions(+), 59 deletions(-) diff --git a/pfc/main.py b/pfc/main.py index 3945c10ee1..071b4a304e 100644 --- a/pfc/main.py +++ b/pfc/main.py @@ -91,7 +91,7 @@ def configPfcPrio(self, status, interface, priority): namespace_str = f" for namespace {self.multi_asic.current_namespace}" if multi_asic.is_multi_asic() else '' if status == 'on' and priority in enable_prio: - click.echo('Priority {0} has already been enabled on {1}{2}'.format(priority, interfacei, namespace_str)) + click.echo('Priority {0} has already been enabled on {1}{2}'.format(priority, interface, namespace_str)) return if status == 'off' and priority not in enable_prio: @@ -122,7 +122,10 @@ def showPfcPrio(self, interface): """The user specifies an interface but we cannot find it""" namespace_str = f"Namespace {self.multi_asic.current_namespace}" if multi_asic.is_multi_asic() else '' if interface and interface not in intfs: - click.echo('Cannot find interface {0} for {1}'.format(interface, namespace_str)) + if multi_asic.is_multi_asic(): + click.echo('Cannot find interface {0} for {1}'.format(interface, namespace_str)) + else: + click.echo('Cannot find interface {0}'.format(interface)) return if interface: @@ -194,4 +197,3 @@ def showPrio(interface, namespace): config.add_command(configPrio, "priority") show.add_command(showAsym, "asymmetric") show.add_command(showPrio, "priority") - diff --git a/tests/multi_asic_pfc_test.py b/tests/multi_asic_pfc_test.py index f1206c45fd..52bfcf4982 100644 --- a/tests/multi_asic_pfc_test.py +++ b/tests/multi_asic_pfc_test.py @@ -131,4 +131,3 @@ def teardown_class(cls): super().teardown_class() os.environ.pop("UTILITIES_UNIT_TESTING_TOPOLOGY") - diff --git a/tests/pfc_input/assert_show_output.py b/tests/pfc_input/assert_show_output.py index facb6de47d..2406f8b49f 100644 --- a/tests/pfc_input/assert_show_output.py +++ b/tests/pfc_input/assert_show_output.py @@ -6,7 +6,7 @@ """ pfc_cannot_find_intf = """\ -Cannot find interface Ethernet1234 for +Cannot find interface Ethernet1234 """ pfc_show_asymmetric_all = """\ diff --git a/tests/pfc_input/pfc_test_vectors.py b/tests/pfc_input/pfc_test_vectors.py index 3c4d447cde..20d6b59af3 100644 --- a/tests/pfc_input/pfc_test_vectors.py +++ b/tests/pfc_input/pfc_test_vectors.py @@ -168,35 +168,35 @@ 'asic0'], 'rc': 0, 'rc_output': show_asym_intf_one_masic - }, + }, 'pfc_show_asymmetric_intf_all_masic': {'cmd': ['show', 'asymmetric', 'Ethernet0'], 'rc': 0, 'rc_output': show_asym_intf_all_masic - }, + }, 'pfc_show_asymmetric_intf_fake_one_masic': {'cmd': ['show', 'asymmetric', - 'Ethernet1234', '--namespace', - 'asic0'], - 'rc': 0, - 'rc_output': show_asym_intf_fake_one_masic - }, + 'Ethernet1234', '--namespace', + 'asic0'], + 'rc': 0, + 'rc_output': show_asym_intf_fake_one_masic + }, 'pfc_show_priority_all_asic0_masic': {'cmd': ['show', 'priority', '--namespace', 'asic0'], - 'rc': 0, - 'rc_output': show_prio_all_asic0_masic - }, + 'rc': 0, + 'rc_output': show_prio_all_asic0_masic + }, 'pfc_show_priority_all_asic1_masic': {'cmd': ['show', 'priority', - '--namespace', 'asic1'], - 'rc': 0, - 'rc_output': show_prio_all_asic1_masic - }, + '--namespace', 'asic1'], + 'rc': 0, + 'rc_output': show_prio_all_asic1_masic + }, 'pfc_show_priority_all_masic': {'cmd': ['show', 'priority'], - 'rc': 0, - 'rc_output': show_prio_all_masic - }, + 'rc': 0, + 'rc_output': show_prio_all_masic + }, 'pfc_show_priority_intf_one_masic': {'cmd': ['show', 'priority', - 'Ethernet0', '--namespace', - 'asic0'], + 'Ethernet0', '--namespace', + 'asic0'], 'rc': 0, 'rc_output': show_prio_intf_one_masic }, @@ -206,21 +206,21 @@ 'rc_output': show_prio_intf_all_masic }, 'pfc_show_priority_intf_fake_one_masic': {'cmd': ['show', 'priority', - 'Ethernet1234', '--namespace', - 'asic0'], - 'rc': 0, - 'rc_output': show_prio_intf_fake_one_masic - }, + 'Ethernet1234', '--namespace', + 'asic0'], + 'rc': 0, + 'rc_output': show_prio_intf_fake_one_masic + }, 'pfc_show_priority_intf_fake_all_masic': {'cmd': ['show', 'priority', - 'Ethernet1234'], + 'Ethernet1234'], 'rc': 0, 'rc_output': show_prio_intf_fake_all_masic - }, + }, 'pfc_config_asymmetric_one_masic': {'cmd': ['config', 'asymmetric', 'on', 'Ethernet0', '--namespace', 'asic0'], 'rc': 0, - 'cmp_args': [['asic0','PORT','Ethernet0','pfc_asym','on']] + 'cmp_args': [['asic0', 'PORT', 'Ethernet0', 'pfc_asym', 'on']] }, 'pfc_config_asymmetric_invalid_one_masic': {'cmd': ['config', 'asymmetric', 'onn', 'Ethernet0', '--namespace', @@ -231,12 +231,12 @@ 'asymmetric --help" for help.\n\n' 'Error: Invalid value for "[on|off]": ' 'invalid choice: onn. (choose from on, off)') - }, + }, 'pfc_config_asymmetric_all_masic': {'cmd': ['config', 'asymmetric', 'on', 'Ethernet0'], 'rc': 0, - 'cmp_args': [['asic0','PORT','Ethernet0','pfc_asym','on'], - ['asic1','PORT','Ethernet0','pfc_asym','on']] + 'cmp_args': [['asic0', 'PORT', 'Ethernet0', 'pfc_asym', 'on'], + ['asic1', 'PORT', 'Ethernet0', 'pfc_asym', 'on']] }, 'pfc_config_asymmetric_invalid_all_masic': {'cmd': ['config', 'asymmetric', 'onn', 'Ethernet0'], @@ -246,38 +246,41 @@ 'asymmetric --help" for help.\n\n' 'Error: Invalid value for "[on|off]": ' 'invalid choice: onn. (choose from on, off)') - }, + }, 'pfc_config_priority_one_masic': {'cmd': ['config', 'priority', 'on', 'Ethernet0', '5', '--namespace', 'asic0'], 'rc': 0, - 'cmp_args': [['asic0','PORT_QOS_MAP','Ethernet0','pfc_enable','3,4,5']] + 'cmp_args': [['asic0', 'PORT_QOS_MAP', 'Ethernet0', + 'pfc_enable', '3,4,5']] }, 'pfc_config_priority_invalid_one_masic': {'cmd': ['config', 'priority', 'onn', 'Ethernet0', '5', '--namespace', 'asic0'], - 'rc': 2, - 'rc_msg': ('Usage: cli config priority [OPTIONS] ' - '[on|off] INTERFACE [0|1|2|3|4|5|6|7]\n' - 'Try "cli config priority --help" for ' - 'help.\n\nError: Invalid value for ' - '"[on|off]": invalid choice: onn. ' - '(choose from on, off)') - }, + 'rc': 2, + 'rc_msg': ('Usage: cli config priority [OPTIONS] ' + '[on|off] INTERFACE [0|1|2|3|4|5|6|7]\n' + 'Try "cli config priority --help" for ' + 'help.\n\nError: Invalid value for ' + '"[on|off]": invalid choice: onn. ' + '(choose from on, off)') + }, 'pfc_config_priority_all_masic': {'cmd': ['config', 'priority', - 'on', 'Ethernet0', '5'], - 'rc': 0, - 'cmp_args': [['asic0','PORT_QOS_MAP','Ethernet0','pfc_enable','3,4,5'], - ['asic1','PORT_QOS_MAP','Ethernet0', 'pfc_enable', '3,4,5']] - }, + 'on', 'Ethernet0', '5'], + 'rc': 0, + 'cmp_args': [['asic0', 'PORT_QOS_MAP', 'Ethernet0', + 'pfc_enable', '3,4,5'], + ['asic1', 'PORT_QOS_MAP', 'Ethernet0', + 'pfc_enable', '3,4,5']] + }, 'pfc_config_priority_invalid_all_masic': {'cmd': ['config', 'priority', - 'onn', 'Ethernet0', '5'], - 'rc': 2, - 'rc_msg': ('Usage: cli config priority [OPTIONS] ' - '[on|off] INTERFACE [0|1|2|3|4|5|6|7]\n' - 'Try "cli config priority --help" for ' - 'help.\n\nError: Invalid value for ' - '"[on|off]": invalid choice: onn. ' - '(choose from on, off)') - }, + 'onn', 'Ethernet0', '5'], + 'rc': 2, + 'rc_msg': ('Usage: cli config priority [OPTIONS] ' + '[on|off] INTERFACE [0|1|2|3|4|5|6|7]\n' + 'Try "cli config priority --help" for ' + 'help.\n\nError: Invalid value for ' + '"[on|off]": invalid choice: onn. ' + '(choose from on, off)') + }, }