示例#1
0
    def test_unixhost_get_version(self):
        uobject = MagicMock(spec=UnixHost)

        uobject.shell.return_value.response.return_value = " test"
        self.assertIsNone(UnixHost.get_version(uobject))

        uobject.shell.return_value.response.return_value = "15.1"
        self.assertEqual(UnixHost.get_version(uobject), "15.1")

        uobject.version = "17.2"
        self.assertEqual(UnixHost.get_version(uobject), "17.2")
示例#2
0
    def test_unixhost_get_version_failure(self):

        uobject = MagicMock(spec=UnixHost)
        uobject.name = 'foo'
        uobject.channels = []

        # Exception
        uobject.shell.side_effect = Exception

        try:
            UnixHost.get_version(uobject)
        except Exception as exp:
            self.assertEqual(exp.args[0], "Could not get version info")