Example #1
0
 def setUp(self) -> None:
     engine = IdealNoDelayGetOutput('myhostname', 'myhostname#')
     engine.load_canned_response('terminal length 0\nmyhostname#')
     engine.load_canned_response(
         'show version\nmyhostname uptime is 5 days, 13 hours, 17 minutes\nmyhostname#'
     )
     self.ssh = IOS(engine)
 def test_returns_prompt_from_transport_engine(self):
     engine = IdealNoDelayGetOutput('myhostname', 'myhostname#')
     ssh = IOS(engine)
     self.assertEqual(ssh.transport.prompt, ssh.prompt)
     # change the prompt in the transport engine and retest to confirm
     ssh.transport.prompt = 'mynewprompt#'
     self.assertEqual('mynewprompt#', ssh.prompt)
Example #3
0
    def test_raises_exception_if_no_enable_password_and_not_in_priv_exec(self):
        engine = IdealNoDelayGetOutput('myhostname', 'myhostname>')
        engine.load_canned_response('terminal length 0\nmyhostname>')
        engine.load_canned_response('enable\n')
        engine.load_canned_response(
            'show interfaces\nline1\nline2\nline3\nline4\nmyhostname>')
        ssh = IOS(engine)

        # need to wrap in a function so it can be called by assertRaises
        def wrap():
            _ = ssh.interfaces

        self.assertRaises(EnablePasswordError, wrap)
Example #4
0
    def test_raises_exception_if_no_enable_password_and_not_in_priv_exec(self):
        engine = IdealNoDelayGetOutput('myhostname', 'myhostname>')
        engine.load_canned_response('terminal length 0\nmyhostname>')
        engine.load_canned_response('enable\n')
        engine.load_canned_response(
            'show version\nmyhostname uptime is 5 days, 13 hours, 17 minutes\nmyhostname>'
        )
        ssh = IOS(engine)

        # need to wrap in a function so it can be called by assertRaises
        def wrap():
            _ = ssh.uptime

        self.assertRaises(EnablePasswordError, wrap)
Example #5
0
 def setUp(self) -> None:
     engine = IdealNoDelayGetOutput('myhostname', 'myhostname#')
     engine.load_canned_response('terminal length 0\nmyhostname#')
     engine.load_canned_response(
         'show interfaces\nline1\nline2\nline3\nline4\nmyhostname#')
     self.ssh = IOS(engine)
 def engine_at_config_mode_prompt(self):
     ssh = IdealNoDelayGetOutput('myhostname', 'myhostname(config)#')
     return IOS(ssh)
 def engine_at_priv_exec_prompt(self):
     ssh = IdealNoDelayGetOutput('myhostname', 'myhostname#')
     return IOS(ssh)
 def engine_at_std_user_prompt(self):
     ssh = IdealNoDelayGetOutput('myhostname', 'myhostname>')
     return IOS(ssh)