Example #1
0
 def test_returns_as_list(self):
     ssh = IdealNoDelayGetOutput()
     file = self.random_files(1)[0]
     with open(file, 'r') as f:
         resp = f.read()
     ssh.load_canned_response(resp)
     data = ssh.get_output()
     self.assertTrue(type(data) == list)
Example #2
0
 def test_output_ends_with_prompt(self):
     ssh = IdealNoDelayGetOutput()
     file = self.random_files(1)[0]
     with open(file, 'r') as f:
         resp = f.read()
     ssh.load_canned_response(resp)
     data = ssh.get_output()
     self.assertEqual(data[-1], resp.splitlines()[-1])
Example #3
0
    def test_returns_all_what_was_sent_from_server(self):
        ssh = IdealNoDelayGetOutput()
        for file in self.files:
            with open(file, 'r') as f:
                canned_resp = f.read()
            # load a canned response
            ssh.load_canned_response(canned_resp)

            data = ssh.get_output()
            self.assertEqual(canned_resp.splitlines(), data)
Example #4
0
 def test_does_not_get_output_by_default_if_no_command_was_sent(self):
     ssh = IdealNoDelayGetOutput()
     # load a command so the engine will return data as long as it runs
     # I need this for proof that it does not return after we rig it
     loaded_response = 'hostname\ntext\nhostname>'
     ssh.load_canned_response(loaded_response)
     # rig engine to believe no command was sent
     ssh.commands_sent_since_last_output_get = 0
     data = ssh.get_output()
     self.assertNotEqual(loaded_response.splitlines(), data)
     self.assertEqual([], data)