|
| 1 | +#!/usr/bin/env python |
| 2 | + |
| 3 | +# This file is part of parallel-ssh. |
| 4 | + |
| 5 | +# Copyright (C) 2015- Panos Kittenis |
| 6 | + |
| 7 | +# This library is free software; you can redistribute it and/or |
| 8 | +# modify it under the terms of the GNU Lesser General Public |
| 9 | +# License as published by the Free Software Foundation, version 2.1. |
| 10 | + |
| 11 | +# This library is distributed in the hope that it will be useful, |
| 12 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | +# Lesser General Public License for more details. |
| 15 | + |
| 16 | +# You should have received a copy of the GNU Lesser General Public |
| 17 | +# License along with this library; if not, write to the Free Software |
| 18 | +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 19 | + |
| 20 | + |
| 21 | +"""Unittests for :mod:`pssh.output.HostOutput` class""" |
| 22 | + |
| 23 | + |
| 24 | +import unittest |
| 25 | +from pssh.output import HostOutput |
| 26 | + |
| 27 | + |
| 28 | +class TestHostOutput(unittest.TestCase): |
| 29 | + |
| 30 | + def setUp(self): |
| 31 | + self.output = HostOutput(None, None, None, None, None, None) |
| 32 | + |
| 33 | + def test_update(self): |
| 34 | + host, cmd, chan, stdout, stderr, \ |
| 35 | + stdin, exit_code, exception = 'host', 'cmd', 'chan', 'stdout', \ |
| 36 | + 'stderr', 'stdin', 1, Exception() |
| 37 | + self.output.update({'host': host, |
| 38 | + 'cmd': cmd, |
| 39 | + 'channel': chan, |
| 40 | + 'stdout': stdout, |
| 41 | + 'stderr': stderr, |
| 42 | + 'stdin': stdin, |
| 43 | + 'exit_code': exit_code, |
| 44 | + 'exception': exception}) |
| 45 | + self.assertEqual(host, self.output.host) |
| 46 | + self.assertEqual(self.output.host, self.output['host']) |
| 47 | + self.assertEqual(cmd, self.output.cmd) |
| 48 | + self.assertEqual(self.output.cmd, self.output['cmd']) |
| 49 | + self.assertEqual(chan, self.output.channel) |
| 50 | + self.assertEqual(self.output.channel, self.output['channel']) |
| 51 | + self.assertEqual(stdout, self.output.stdout) |
| 52 | + self.assertEqual(self.output.stdout, self.output['stdout']) |
| 53 | + self.assertEqual(stderr, self.output.stderr) |
| 54 | + self.assertEqual(self.output.stderr, self.output['stderr']) |
| 55 | + self.assertEqual(stdin, self.output.stdin) |
| 56 | + self.assertEqual(self.output.stdin, self.output['stdin']) |
| 57 | + self.assertEqual(exit_code, self.output.exit_code) |
| 58 | + self.assertEqual(self.output.exit_code, self.output['exit_code']) |
| 59 | + self.assertEqual(exception, self.output.exception) |
| 60 | + self.assertEqual(self.output.exception, self.output['exception']) |
0 commit comments