- Fix to return error message back to the module. (#31035)

This commit is contained in:
Kedar K 2017-09-29 17:06:30 +05:30 committed by GitHub
commit 916e6be888
3 changed files with 48 additions and 8 deletions

View file

@ -42,12 +42,42 @@ class TestNxosBannerModule(TestNxosModule):
def load_fixtures(self, commands=None, device=''):
self.load_config.return_value = dict(diff=None, session='session')
def test_nxos_banner_create(self):
def test_nxos_banner_exec_create(self):
set_module_args(dict(banner='exec', text='test\nbanner\nstring'))
commands = ['banner exec @\ntest\nbanner\nstring\n@']
self.run_commands.return_value = commands
self.execute_module(changed=True, commands=commands)
def test_nxos_banner_remove(self):
def test_nxos_banner_exec_remove(self):
set_module_args(dict(banner='exec', state='absent'))
commands = ['no banner exec']
self.run_commands.return_value = commands
self.execute_module(changed=True, commands=commands)
def test_nxos_banner_exec_fail_create(self):
set_module_args(dict(banner='exec', text='test\nbanner\nstring'))
commands = ['banner exec @\ntest\nbanner\nstring\n@']
err_rsp = ['Invalid command']
self.run_commands.return_value = err_rsp
result = self.execute_module(failed=True, changed=True)
self.assertEqual(result['msg'], 'banner: exec may not be supported on this platform. Possible values are : exec | motd')
def test_nxos_banner_exec_fail_remove(self):
set_module_args(dict(banner='exec', state='absent'))
commands = ['no banner exec']
err_rsp = ['Invalid command']
self.run_commands.return_value = err_rsp
result = self.execute_module(failed=True, changed=True)
self.assertEqual(result['msg'], 'banner: exec may not be supported on this platform. Possible values are : exec | motd')
def test_nxos_banner_motd_create(self):
set_module_args(dict(banner='motd', text='test\nbanner\nstring'))
commands = ['banner motd @\ntest\nbanner\nstring\n@']
self.run_commands.return_value = commands
self.execute_module(changed=True, commands=commands)
def test_nxos_banner_motd_remove(self):
set_module_args(dict(banner='motd', state='absent'))
commands = ['no banner motd']
self.run_commands.return_value = commands
self.execute_module(changed=True, commands=commands)