Skip to content

Commit

Permalink
Fixed pre-commit errors
Browse files Browse the repository at this point in the history
  • Loading branch information
arista-hpandya committed Jan 28, 2025
1 parent 4f38e99 commit 1818a66
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
29 changes: 21 additions & 8 deletions tests/config_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3182,6 +3182,7 @@ def test_remove_reasons(self, mock_run_command):
def teardown(self):
print("TEARDOWN")


class TestConfigDropcountersMasic(object):
def setup(self):
print("SETUP")
Expand All @@ -3206,46 +3207,58 @@ def test_install_multi_asic(self, mock_run_command):
namespace = 'asic0'

runner = CliRunner()
result = runner.invoke(config.config.commands['dropcounters'].commands['install'], [counter_name, counter_type, reasons, '-d', desc, '-g', group, '-a', alias, '-n', namespace])
result = runner.invoke(config.config.commands['dropcounters'].commands['install'],
[counter_name, counter_type, reasons, '-d', desc, '-g', group, '-a',
alias, '-n', namespace])
print(result.exit_code)
print(result.output)
assert result.exit_code == 0
mock_run_command.assert_called_once_with(['dropconfig', '-c', 'install', '-n', str(counter_name), '-t', str(counter_type), '-r', str(reasons), '-a', str(alias), '-g', str(group), '-d', str(desc), '-ns', str(namespace)], display_cmd=False)
mock_run_command.assert_called_once_with(['dropconfig', '-c', 'install', '-n', str(counter_name),
'-t', str(counter_type), '-r', str(reasons), '-a', str(alias),
'-g', str(group), '-d', str(desc),
'-ns', str(namespace)], display_cmd=False)

@patch('utilities_common.cli.run_command')
def test_delete_multi_asic(self, mock_run_command):
counter_name = 'DEBUG_2'
namespace = 'asic0'
runner = CliRunner()
result = runner.invoke(config.config.commands['dropcounters'].commands['delete'], [counter_name, '-v', '-n', namespace])
result = runner.invoke(config.config.commands['dropcounters'].commands['delete'],
[counter_name, '-v', '-n', namespace])
print(result.exit_code)
print(result.output)
assert result.exit_code == 0
mock_run_command.assert_called_once_with(['dropconfig', '-c', 'uninstall', '-n', str(counter_name), '-ns', namespace], display_cmd=True)
mock_run_command.assert_called_once_with(['dropconfig', '-c', 'uninstall', '-n',
str(counter_name), '-ns', namespace], display_cmd=True)

@patch('utilities_common.cli.run_command')
def test_add_reasons_multi_asic(self, mock_run_command):
counter_name = 'DEBUG_2'
reasons = '[EXCEEDS_L2_MTU,DECAP_ERROR]'
namespace = 'asic0'
runner = CliRunner()
result = runner.invoke(config.config.commands['dropcounters'].commands['add-reasons'], [counter_name, reasons, '-v', '-n', namespace])
result = runner.invoke(config.config.commands['dropcounters'].commands['add-reasons'],
[counter_name, reasons, '-v', '-n', namespace])
print(result.exit_code)
print(result.output)
assert result.exit_code == 0
mock_run_command.assert_called_once_with(['dropconfig', '-c', 'add', '-n', str(counter_name), '-r', str(reasons), '-ns', namespace], display_cmd=True)
mock_run_command.assert_called_once_with(['dropconfig', '-c', 'add', '-n',
str(counter_name), '-r', str(reasons), '-ns', namespace],
display_cmd=True)

@patch('utilities_common.cli.run_command')
def test_remove_reasons_multi_asic(self, mock_run_command):
counter_name = 'DEBUG_2'
reasons = '[EXCEEDS_L2_MTU,DECAP_ERROR]'
namespace = 'asic0'
runner = CliRunner()
result = runner.invoke(config.config.commands['dropcounters'].commands['remove-reasons'], [counter_name, reasons, '-v', '-n', namespace])
result = runner.invoke(config.config.commands['dropcounters'].commands['remove-reasons'],
[counter_name, reasons, '-v', '-n', namespace])
print(result.exit_code)
print(result.output)
assert result.exit_code == 0
mock_run_command.assert_called_once_with(['dropconfig', '-c', 'remove', '-n', str(counter_name), '-r', str(reasons), '-ns', namespace], display_cmd=True)
mock_run_command.assert_called_once_with(['dropconfig', '-c', 'remove', '-n', str(counter_name),
'-r', str(reasons), '-ns', namespace], display_cmd=True)

@classmethod
def teardown_class(cls):
Expand Down
3 changes: 2 additions & 1 deletion tests/drops_group_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ def test_show_configuration(self):

def test_show_configuration_with_group(self):
runner = CliRunner()
result = runner.invoke(show.cli.commands["dropcounters"].commands["configuration"], ["-g", "PACKET_DROPS", '-n', 'asic0'])
result = runner.invoke(show.cli.commands["dropcounters"].commands["configuration"],
["-g", "PACKET_DROPS", '-n', 'asic0'])
print(result.output)
assert result.output == "For namespace: asic0\n" + expected_counter_configuration_with_group

Expand Down

0 comments on commit 1818a66

Please sign in to comment.