@ -39,22 +39,42 @@ class TestEosBannerModule(TestEosModule):
self . mock_run_commands . stop ( )
self . mock_load_config . stop ( )
def load_fixtures ( self , commands = None ) :
def load_fixtures ( self , commands = None , transport = ' cli ' ) :
if transport == ' cli ' :
self . run_commands . return_value = [ load_fixture ( ' eos_banner_show_banner.txt ' ) . strip ( ) ]
else :
self . run_commands . return_value = [ { ' loginBanner ' : load_fixture ( ' eos_banner_show_banner.txt ' ) . strip ( ) } ]
self . load_config . return_value = dict ( diff = None , session = ' session ' )
def test_eos_banner_create ( self ) :
set_module_args ( dict ( banner = ' login ' , text = ' test \n banner \n string ' ) )
def test_eos_banner_create_with_cli_transport ( self ) :
set_module_args ( dict ( banner = ' login ' , text = ' test \n banner \n string ' ,
transport = ' cli ' ) )
commands = [ ' banner login ' , ' test ' , ' banner ' , ' string ' , ' EOF ' ]
self . execute_module ( changed = True , commands = commands )
def test_eos_banner_remove ( self ) :
set_module_args ( dict ( banner = ' login ' , state = ' absent ' ) )
def test_eos_banner_create_with_eapi_transport ( self ) :
set_module_args ( dict ( banner = ' login ' , text = ' test \n banner \n string ' ,
transport = ' eapi ' ) )
commands = [ { ' cmd ' : ' banner login ' , ' input ' : ' test \n banner \n string ' } ]
self . execute_module ( changed = True , commands = commands , transport = ' eapi ' )
def test_eos_banner_remove_with_cli_transport ( self ) :
set_module_args ( dict ( banner = ' login ' , state = ' absent ' , transport = ' cli ' ) )
commands = [ ' no banner login ' ]
self . execute_module ( changed = True , commands = commands )
def test_eos_banner_nochange ( self ) :
def test_eos_banner_remove_with_eapi_transport ( self ) :
set_module_args ( dict ( banner = ' login ' , state = ' absent ' , transport = ' eapi ' ) )
commands = [ ' no banner login ' ]
self . execute_module ( changed = True , commands = commands , transport = ' eapi ' )
def test_eos_banner_nochange_with_cli_transport ( self ) :
banner_text = load_fixture ( ' eos_banner_show_banner.txt ' ) . strip ( )
set_module_args ( dict ( banner = ' login ' , text = banner_text ) )
set_module_args ( dict ( banner = ' login ' , text = banner_text , transport = ' cli ' ))
self . execute_module ( )
def test_eos_banner_nochange_with_eapi_transport ( self ) :
banner_text = load_fixture ( ' eos_banner_show_banner.txt ' ) . strip ( )
set_module_args ( dict ( banner = ' login ' , text = banner_text , transport = ' eapi ' ) )
self . execute_module ( transport = ' eapi ' )