Exemple #1
0
class TestHostOutput(unittest.TestCase):
    def setUp(self):
        self.output = HostOutput(None, None, None, None, None, None)

    def test_update(self):
        host, cmd, chan, stdout, stderr, \
          stdin, exit_code, exception = 'host', 'cmd', 'chan', 'stdout', \
          'stderr', 'stdin', 1, Exception()
        self.output.update({
            'host': host,
            'cmd': cmd,
            'channel': chan,
            'stdout': stdout,
            'stderr': stderr,
            'stdin': stdin,
            'exit_code': exit_code,
            'exception': exception
        })
        self.assertEqual(host, self.output.host)
        self.assertEqual(self.output.host, self.output['host'])
        self.assertEqual(cmd, self.output.cmd)
        self.assertEqual(self.output.cmd, self.output['cmd'])
        self.assertEqual(chan, self.output.channel)
        self.assertEqual(self.output.channel, self.output['channel'])
        self.assertEqual(stdout, self.output.stdout)
        self.assertEqual(self.output.stdout, self.output['stdout'])
        self.assertEqual(stderr, self.output.stderr)
        self.assertEqual(self.output.stderr, self.output['stderr'])
        self.assertEqual(stdin, self.output.stdin)
        self.assertEqual(self.output.stdin, self.output['stdin'])
        self.assertEqual(exit_code, self.output.exit_code)
        self.assertEqual(self.output.exit_code, self.output['exit_code'])
        self.assertEqual(exception, self.output.exception)
        self.assertEqual(self.output.exception, self.output['exception'])
class TestHostOutput(unittest.TestCase):
    def setUp(self):
        self.output = HostOutput(None, None, None, None, None, None, True)

    def test_print(self):
        self.assertTrue(str(self.output))

    def test_update(self):
        host, cmd, chan, stdout, stderr, \
          stdin, exception = 'host', 'cmd', 'chan', 'stdout', \
          'stderr', 'stdin', Exception()
        self.output.update({
            'host': host,
            'cmd': cmd,
            'channel': chan,
            'stdout': stdout,
            'stderr': stderr,
            'stdin': stdin,
            'exception': exception
        })
        self.assertEqual(host, self.output.host)
        self.assertEqual(self.output.host, self.output['host'])
        self.assertEqual(cmd, self.output.cmd)
        self.assertEqual(self.output.cmd, self.output['cmd'])
        self.assertEqual(chan, self.output.channel)
        self.assertEqual(self.output.channel, self.output['channel'])
        self.assertEqual(stdout, self.output.stdout)
        self.assertEqual(self.output.stdout, self.output['stdout'])
        self.assertEqual(stderr, self.output.stderr)
        self.assertEqual(self.output.stderr, self.output['stderr'])
        self.assertEqual(stdin, self.output.stdin)
        self.assertEqual(self.output.stdin, self.output['stdin'])
        self.assertEqual(exception, self.output.exception)
        self.assertEqual(self.output.exception, self.output['exception'])

    def test_bad_exit_status(self):
        self.assertEqual(self.output.exit_code, None)

    def test_excepting_client_exit_code(self):
        class ExcSSHClient(object):
            def get_exit_status(self, channel):
                raise Exception

        exc_client = ExcSSHClient()
        host_out = HostOutput('host', None, None, None, None, None, exc_client,
                              None)
        exit_code = host_out.exit_code
        self.assertEqual(exit_code, None)
 def test_none_output_client(self):
     host_out = HostOutput(
         'host', None, None, client=None)
     exit_code = host_out.exit_code
     self.assertEqual(exit_code, None)
     self.assertIsNone(host_out.stdout)
     self.assertIsNone(host_out.stderr)
 def setUp(self):
     self.output = HostOutput(
         None, None, None, None,
         buffers=HostOutputBuffers(
             BufferData(None, None),
             BufferData(None, None),
         )
     )
    def test_excepting_client_exit_code(self):
        class ExcSSHClient(object):
            def get_exit_status(self, channel):
                raise Exception

        exc_client = ExcSSHClient()
        host_out = HostOutput('host', None, None, None, None, exc_client)
        exit_code = host_out.exit_code
        self.assertEqual(exit_code, None)
 def test_excepting_client_exit_code(self):
     class ChannelError(Exception):
         pass
     class ExcSSHClient(object):
         def get_exit_status(self, channel):
             raise ChannelError
     exc_client = ExcSSHClient()
     host_out = HostOutput(
         'host', None, None, client=exc_client)
     exit_code = host_out.exit_code
     self.assertIsNone(exit_code)
class TestHostOutput(unittest.TestCase):

    def setUp(self):
        self.output = HostOutput(None, None, None, None, None, None)

    def test_print(self):
        self.assertTrue(str(self.output))

    def test_update(self):
        host, cmd, chan, stdout, stderr, \
          stdin, exit_code, exception = 'host', 'cmd', 'chan', 'stdout', \
          'stderr', 'stdin', 1, Exception()
        self.output.update({'host': host,
                            'cmd': cmd,
                            'channel': chan,
                            'stdout': stdout,
                            'stderr': stderr,
                            'stdin': stdin,
                            'exit_code': exit_code,
                            'exception': exception})
        self.assertEqual(host, self.output.host)
        self.assertEqual(self.output.host, self.output['host'])
        self.assertEqual(cmd, self.output.cmd)
        self.assertEqual(self.output.cmd, self.output['cmd'])
        self.assertEqual(chan, self.output.channel)
        self.assertEqual(self.output.channel, self.output['channel'])
        self.assertEqual(stdout, self.output.stdout)
        self.assertEqual(self.output.stdout, self.output['stdout'])
        self.assertEqual(stderr, self.output.stderr)
        self.assertEqual(self.output.stderr, self.output['stderr'])
        self.assertEqual(stdin, self.output.stdin)
        self.assertEqual(self.output.stdin, self.output['stdin'])
        self.assertEqual(exit_code, self.output.exit_code)
        self.assertEqual(self.output.exit_code, self.output['exit_code'])
        self.assertEqual(exception, self.output.exception)
        self.assertEqual(self.output.exception, self.output['exception'])
 def setUp(self):
     self.output = HostOutput(None, None, None, None, None, None, True)
 def setUp(self):
     self.output = HostOutput(None, None, None, None, None, None)
 def test_join_bad_host_out(self):
     out = HostOutput(None, None, None, None)
     self.assertIsNone(self.client._join(out))
     self.assertIsNone(self.client._join(None))
     self.assertIsNone(self.client.join([None]))