Skip to content

Commit 7a7f9f7

Browse files
committed
Added Banner CLI UTs
Signed-off-by: Yevhen Fastiuk <[email protected]>
1 parent 197e49a commit 7a7f9f7

File tree

3 files changed

+66
-1
lines changed

3 files changed

+66
-1
lines changed

config/main.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7770,7 +7770,6 @@ def state(state):
77707770
{'state': state})
77717771

77727772

7773-
77747773
@banner.command()
77757774
@click.argument('message', metavar='<message>', required=True)
77767775
def login(message):

tests/config_test.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3093,3 +3093,63 @@ def teardown_class(cls):
30933093
from .mock_tables import mock_single_asic
30943094
importlib.reload(mock_single_asic)
30953095
dbconnector.load_database_config()
3096+
3097+
3098+
class TestConfigBanner(object):
3099+
@classmethod
3100+
def setup_class(cls):
3101+
print('SETUP')
3102+
import config.main
3103+
importlib.reload(config.main)
3104+
3105+
@patch('utilities_common.cli.run_command',
3106+
mock.MagicMock(side_effect=mock_run_command_side_effect))
3107+
def test_banner_state(self):
3108+
runner = CliRunner()
3109+
obj = {'db': Db().cfgdb}
3110+
3111+
result = runner.invoke(
3112+
config.config.commands['banner'].commands['state'],
3113+
['enabled'], obj=obj)
3114+
3115+
assert result.exit_code == 0
3116+
3117+
@patch('utilities_common.cli.run_command',
3118+
mock.MagicMock(side_effect=mock_run_command_side_effect))
3119+
def test_banner_login(self):
3120+
runner = CliRunner()
3121+
obj = {'db': Db().cfgdb}
3122+
3123+
result = runner.invoke(
3124+
config.config.commands['banner'].commands['login'],
3125+
['Login message'], obj=obj)
3126+
3127+
assert result.exit_code == 0
3128+
3129+
@patch('utilities_common.cli.run_command',
3130+
mock.MagicMock(side_effect=mock_run_command_side_effect))
3131+
def test_banner_logout(self):
3132+
runner = CliRunner()
3133+
obj = {'db': Db().cfgdb}
3134+
3135+
result = runner.invoke(
3136+
config.config.commands['banner'].commands['logout'],
3137+
['Logout message'], obj=obj)
3138+
3139+
assert result.exit_code == 0
3140+
3141+
@patch('utilities_common.cli.run_command',
3142+
mock.MagicMock(side_effect=mock_run_command_side_effect))
3143+
def test_banner_motd(self):
3144+
runner = CliRunner()
3145+
obj = {'db': Db().cfgdb}
3146+
3147+
result = runner.invoke(
3148+
config.config.commands['banner'].commands['motd'],
3149+
['Motd message'], obj=obj)
3150+
3151+
assert result.exit_code == 0
3152+
3153+
@classmethod
3154+
def teardown_class(cls):
3155+
print('TEARDOWN')

tests/show_test.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,6 +1040,12 @@ def test_show_ztp(self, mock_run_command):
10401040
assert result.exit_code == 0
10411041
mock_run_command.assert_called_with(['ztp', 'status', '--verbose'], display_cmd=True)
10421042

1043+
@patch('show.main.run_command')
1044+
def test_show_banner(self, mock_run_command):
1045+
runner = CliRunner()
1046+
result = runner.invoke(show.cli.commands['banner'])
1047+
assert result.exit_code == 0
1048+
10431049
def teardown(self):
10441050
print('TEAR DOWN')
10451051

0 commit comments

Comments
 (0)