def test_trim_buffer_with_execute(self): c = Connection(hostname='ncs', start=['mock_device_cli --os confd --state cisco_exec'], os='confd', username='******', tacacs_password='******') c.connect() c.settings.IGNORE_CHATTY_TERM_OUTPUT = True c.sendline('rest commit') r = c.execute('show services') self.assertEqual( r.replace('\r', ''), mock_data['cisco_exec']['commands'] ['show services']['response'].rstrip())
def test_connect_with_setup_mgmt(self): c = Connection( hostname='Router', start=['mock_device_cli --os ios --state enable'], os='ios', username='******', enable_password='******', tacacs_password='******', # init_exec_commands=[], init_config_commands=[]) c.connect() c.sendline('setup_mgmt') c.connection_provider.connect() self.assertEqual(c.state_machine.current_state, 'enable')
def test_log_message_before_prompt(self): c = Connection(hostname='R1', start=['mock_device_cli --hostname R1 --os iosxr --state enable'], os='iosxr', username='******', enable_password='******', init_config_commands=[], init_exec_commands=[] ) c.connect() c.settings.IGNORE_CHATTY_TERM_OUTPUT = False c.sendline('process_restart_msg') r = c.execute('show telemetry | inc ACTIVE') self.assertIn("""process_restart_msg 0/RP0/ADMIN0:Jul 7 10:07:42.979 UTC: pm[2890]: %INFRA-Process_Manager-3-PROCESS_RESTART : Process tams (IID: 0) restarted""", r.replace('\r', '')) c.settings.IGNORE_CHATTY_TERM_OUTPUT = True c.sendline('process_restart_msg') r = c.execute('show telemetry | inc ACTIVE') self.assertEqual(r, 'Sat Jul 7 10:08:02.976 UTC\r\nState: ACTIVE')