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 committed Jan 30, 2024
1 parent 3aadba3 commit 42eea90
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
60 changes: 60 additions & 0 deletions tests/config_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2474,3 +2474,63 @@ def test_date_bad(self):
@classmethod
def teardown_class(cls):
print('TEARDOWN')


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 @@ -985,6 +985,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 42eea90

Please sign in to comment.