Skip to content

Commit 1bc8ea7

Browse files
author
Sviatoslav Boichuk
committed
Added Banner CLI UTs
1 parent 440bce0 commit 1bc8ea7

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed

tests/config_test.py

+60
Original file line numberDiff line numberDiff line change
@@ -2474,3 +2474,63 @@ def test_date_bad(self):
24742474
@classmethod
24752475
def teardown_class(cls):
24762476
print('TEARDOWN')
2477+
2478+
2479+
class TestConfigBanner(object):
2480+
@classmethod
2481+
def setup_class(cls):
2482+
print('SETUP')
2483+
import config.main
2484+
importlib.reload(config.main)
2485+
2486+
@patch('utilities_common.cli.run_command',
2487+
mock.MagicMock(side_effect=mock_run_command_side_effect))
2488+
def test_banner_state(self):
2489+
runner = CliRunner()
2490+
obj = {'db': Db().cfgdb}
2491+
2492+
result = runner.invoke(
2493+
config.config.commands['banner'].commands['state'],
2494+
['enabled'], obj=obj)
2495+
2496+
assert result.exit_code == 0
2497+
2498+
@patch('utilities_common.cli.run_command',
2499+
mock.MagicMock(side_effect=mock_run_command_side_effect))
2500+
def test_banner_login(self):
2501+
runner = CliRunner()
2502+
obj = {'db': Db().cfgdb}
2503+
2504+
result = runner.invoke(
2505+
config.config.commands['banner'].commands['login'],
2506+
['Login message'], obj=obj)
2507+
2508+
assert result.exit_code == 0
2509+
2510+
@patch('utilities_common.cli.run_command',
2511+
mock.MagicMock(side_effect=mock_run_command_side_effect))
2512+
def test_banner_logout(self):
2513+
runner = CliRunner()
2514+
obj = {'db': Db().cfgdb}
2515+
2516+
result = runner.invoke(
2517+
config.config.commands['banner'].commands['logout'],
2518+
['Logout message'], obj=obj)
2519+
2520+
assert result.exit_code == 0
2521+
2522+
@patch('utilities_common.cli.run_command',
2523+
mock.MagicMock(side_effect=mock_run_command_side_effect))
2524+
def test_banner_motd(self):
2525+
runner = CliRunner()
2526+
obj = {'db': Db().cfgdb}
2527+
2528+
result = runner.invoke(
2529+
config.config.commands['banner'].commands['motd'],
2530+
['Motd message'], obj=obj)
2531+
2532+
assert result.exit_code == 0
2533+
2534+
@classmethod
2535+
def teardown_class(cls):
2536+
print('TEARDOWN')

tests/show_test.py

+6
Original file line numberDiff line numberDiff line change
@@ -985,6 +985,12 @@ def test_show_ztp(self, mock_run_command):
985985
assert result.exit_code == 0
986986
mock_run_command.assert_called_with(['ztp', 'status', '--verbose'], display_cmd=True)
987987

988+
@patch('show.main.run_command')
989+
def test_show_banner(self, mock_run_command):
990+
runner = CliRunner()
991+
result = runner.invoke(show.cli.commands['banner'])
992+
assert result.exit_code == 0
993+
988994
def teardown(self):
989995
print('TEAR DOWN')
990996

0 commit comments

Comments
 (0)