|
|
@ -30,20 +30,21 @@ class TestIosBannerModule(TestIosModule):
|
|
|
|
def setUp(self):
|
|
|
|
def setUp(self):
|
|
|
|
super(TestIosBannerModule, self).setUp()
|
|
|
|
super(TestIosBannerModule, self).setUp()
|
|
|
|
|
|
|
|
|
|
|
|
self.mock_exec_command = patch('ansible.modules.network.ios.ios_banner.exec_command')
|
|
|
|
self.mock_get_config = patch('ansible.modules.network.ios.ios_banner.get_config')
|
|
|
|
self.exec_command = self.mock_exec_command.start()
|
|
|
|
self.get_config = self.mock_get_config.start()
|
|
|
|
|
|
|
|
|
|
|
|
self.mock_load_config = patch('ansible.modules.network.ios.ios_banner.load_config')
|
|
|
|
self.mock_load_config = patch('ansible.modules.network.ios.ios_banner.load_config')
|
|
|
|
self.load_config = self.mock_load_config.start()
|
|
|
|
self.load_config = self.mock_load_config.start()
|
|
|
|
|
|
|
|
|
|
|
|
def tearDown(self):
|
|
|
|
def tearDown(self):
|
|
|
|
super(TestIosBannerModule, self).tearDown()
|
|
|
|
super(TestIosBannerModule, self).tearDown()
|
|
|
|
self.mock_exec_command.stop()
|
|
|
|
self.mock_get_config.stop()
|
|
|
|
self.mock_load_config.stop()
|
|
|
|
self.mock_load_config.stop()
|
|
|
|
|
|
|
|
|
|
|
|
def load_fixtures(self, commands=None):
|
|
|
|
def load_fixtures(self, commands=None):
|
|
|
|
self.exec_command.return_value = (0, load_fixture('ios_banner_show_banner.txt').strip(), None)
|
|
|
|
def load_from_file(*args, **kwargs):
|
|
|
|
self.load_config.return_value = dict(diff=None, session='session')
|
|
|
|
return load_fixture('ios_banner_show_running_config_ios12.txt')
|
|
|
|
|
|
|
|
self.get_config.side_effect = load_from_file
|
|
|
|
|
|
|
|
|
|
|
|
def test_ios_banner_create(self):
|
|
|
|
def test_ios_banner_create(self):
|
|
|
|
for banner_type in ('login', 'motd', 'exec', 'incoming', 'slip-ppp'):
|
|
|
|
for banner_type in ('login', 'motd', 'exec', 'incoming', 'slip-ppp'):
|
|
|
@ -57,21 +58,19 @@ class TestIosBannerModule(TestIosModule):
|
|
|
|
self.execute_module(changed=True, commands=commands)
|
|
|
|
self.execute_module(changed=True, commands=commands)
|
|
|
|
|
|
|
|
|
|
|
|
def test_ios_banner_nochange(self):
|
|
|
|
def test_ios_banner_nochange(self):
|
|
|
|
banner_text = load_fixture('ios_banner_show_banner.txt').strip()
|
|
|
|
banner_text = load_fixture('ios_banner_show_banner.txt')
|
|
|
|
set_module_args(dict(banner='login', text=banner_text))
|
|
|
|
set_module_args(dict(banner='login', text=banner_text))
|
|
|
|
self.execute_module()
|
|
|
|
self.execute_module()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestIosBannerIos12Module(TestIosBannerModule):
|
|
|
|
class TestIosBannerIos12Module(TestIosBannerModule):
|
|
|
|
|
|
|
|
|
|
|
|
def load_fixtures(self, commands):
|
|
|
|
def load_fixtures(self, commands=None):
|
|
|
|
show_banner_return_value = (1, '', None)
|
|
|
|
def load_from_file(*args, **kwargs):
|
|
|
|
show_running_config_return_value = \
|
|
|
|
return load_fixture('ios_banner_show_running_config_ios12.txt')
|
|
|
|
(0, load_fixture('ios_banner_show_running_config_ios12.txt').strip(), None)
|
|
|
|
self.get_config.side_effect = load_from_file
|
|
|
|
self.exec_command.side_effect = [show_banner_return_value,
|
|
|
|
|
|
|
|
show_running_config_return_value]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_ios_banner_nochange(self):
|
|
|
|
def test_ios_banner_nochange(self):
|
|
|
|
banner_text = load_fixture('ios_banner_show_banner.txt').strip()
|
|
|
|
banner_text = load_fixture('ios_banner_show_banner.txt')
|
|
|
|
set_module_args(dict(banner='exec', text=banner_text))
|
|
|
|
set_module_args(dict(banner='exec', text=banner_text))
|
|
|
|
self.execute_module()
|
|
|
|
self.execute_module()
|
|
|
|