Skip to content

Commit 262226d

Browse files
committed
Added Banner CLI UTs
Signed-off-by: Yevhen Fastiuk <[email protected]>
1 parent e4ea782 commit 262226d

File tree

2 files changed

+67
-1
lines changed

2 files changed

+67
-1
lines changed

tests/config_test.py

+61-1
Original file line numberDiff line numberDiff line change
@@ -2741,4 +2741,64 @@ def teardown_class(cls):
27412741
from .mock_tables import dbconnector
27422742
from .mock_tables import mock_single_asic
27432743
importlib.reload(mock_single_asic)
2744-
dbconnector.load_database_config()
2744+
dbconnector.load_database_config()
2745+
2746+
2747+
class TestConfigBanner(object):
2748+
@classmethod
2749+
def setup_class(cls):
2750+
print('SETUP')
2751+
import config.main
2752+
importlib.reload(config.main)
2753+
2754+
@patch('utilities_common.cli.run_command',
2755+
mock.MagicMock(side_effect=mock_run_command_side_effect))
2756+
def test_banner_state(self):
2757+
runner = CliRunner()
2758+
obj = {'db': Db().cfgdb}
2759+
2760+
result = runner.invoke(
2761+
config.config.commands['banner'].commands['state'],
2762+
['enabled'], obj=obj)
2763+
2764+
assert result.exit_code == 0
2765+
2766+
@patch('utilities_common.cli.run_command',
2767+
mock.MagicMock(side_effect=mock_run_command_side_effect))
2768+
def test_banner_login(self):
2769+
runner = CliRunner()
2770+
obj = {'db': Db().cfgdb}
2771+
2772+
result = runner.invoke(
2773+
config.config.commands['banner'].commands['login'],
2774+
['Login message'], obj=obj)
2775+
2776+
assert result.exit_code == 0
2777+
2778+
@patch('utilities_common.cli.run_command',
2779+
mock.MagicMock(side_effect=mock_run_command_side_effect))
2780+
def test_banner_logout(self):
2781+
runner = CliRunner()
2782+
obj = {'db': Db().cfgdb}
2783+
2784+
result = runner.invoke(
2785+
config.config.commands['banner'].commands['logout'],
2786+
['Logout message'], obj=obj)
2787+
2788+
assert result.exit_code == 0
2789+
2790+
@patch('utilities_common.cli.run_command',
2791+
mock.MagicMock(side_effect=mock_run_command_side_effect))
2792+
def test_banner_motd(self):
2793+
runner = CliRunner()
2794+
obj = {'db': Db().cfgdb}
2795+
2796+
result = runner.invoke(
2797+
config.config.commands['banner'].commands['motd'],
2798+
['Motd message'], obj=obj)
2799+
2800+
assert result.exit_code == 0
2801+
2802+
@classmethod
2803+
def teardown_class(cls):
2804+
print('TEARDOWN')

tests/show_test.py

+6
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)