Skip to content

Commit

Permalink
Added Banner CLI UTs
Browse files Browse the repository at this point in the history
  • Loading branch information
Sviatoslav Boichuk authored and fastiuk committed Apr 27, 2024
1 parent 8b90007 commit f8f1510
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 1 deletion.
62 changes: 61 additions & 1 deletion tests/config_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2741,4 +2741,64 @@ def teardown_class(cls):
from .mock_tables import dbconnector
from .mock_tables import mock_single_asic
importlib.reload(mock_single_asic)
dbconnector.load_database_config()
dbconnector.load_database_config()


class TestConfigBanner(object):
@classmethod
def setup_class(cls):
print('SETUP')
import config.main
importlib.reload(config.main)

@patch('utilities_common.cli.run_command',
mock.MagicMock(side_effect=mock_run_command_side_effect))
def test_banner_state(self):
runner = CliRunner()
obj = {'db': Db().cfgdb}

result = runner.invoke(
config.config.commands['banner'].commands['state'],
['enabled'], obj=obj)

assert result.exit_code == 0

@patch('utilities_common.cli.run_command',
mock.MagicMock(side_effect=mock_run_command_side_effect))
def test_banner_login(self):
runner = CliRunner()
obj = {'db': Db().cfgdb}

result = runner.invoke(
config.config.commands['banner'].commands['login'],
['Login message'], obj=obj)

assert result.exit_code == 0

@patch('utilities_common.cli.run_command',
mock.MagicMock(side_effect=mock_run_command_side_effect))
def test_banner_logout(self):
runner = CliRunner()
obj = {'db': Db().cfgdb}

result = runner.invoke(
config.config.commands['banner'].commands['logout'],
['Logout message'], obj=obj)

assert result.exit_code == 0

@patch('utilities_common.cli.run_command',
mock.MagicMock(side_effect=mock_run_command_side_effect))
def test_banner_motd(self):
runner = CliRunner()
obj = {'db': Db().cfgdb}

result = runner.invoke(
config.config.commands['banner'].commands['motd'],
['Motd message'], obj=obj)

assert result.exit_code == 0

@classmethod
def teardown_class(cls):
print('TEARDOWN')
6 changes: 6 additions & 0 deletions tests/show_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1040,6 +1040,12 @@ def test_show_ztp(self, mock_run_command):
assert result.exit_code == 0
mock_run_command.assert_called_with(['ztp', 'status', '--verbose'], display_cmd=True)

@patch('show.main.run_command')
def test_show_banner(self, mock_run_command):
runner = CliRunner()
result = runner.invoke(show.cli.commands['banner'])
assert result.exit_code == 0

def teardown(self):
print('TEAR DOWN')

Expand Down

0 comments on commit f8f1510

Please sign in to comment.