示例#1
0
    def test_online_success(self):
        '''
        Tests online
        '''
        ret = {}
        ret['stdout'] = ""
        ret['stderr'] = ""
        ret['retcode'] = 0
        mock_cmd = MagicMock(return_value=ret)

        with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \
             patch.dict(zpool.__utils__, self.utils_patch):
            ret = zpool.online('mypool', '/dev/rdsk/c0t0d0')
            res = OrderedDict([('onlined', True)])
            self.assertEqual(ret, res)
示例#2
0
    def test_online_success(self):
        """
        Tests online
        """
        ret = {}
        ret["stdout"] = ""
        ret["stderr"] = ""
        ret["retcode"] = 0
        mock_cmd = MagicMock(return_value=ret)

        with patch.dict(zpool.__salt__, {"cmd.run_all": mock_cmd}), patch.dict(
                zpool.__utils__, self.utils_patch):
            ret = zpool.online("mypool", "/dev/rdsk/c0t0d0")
            res = OrderedDict([("onlined", True)])
            self.assertEqual(ret, res)
示例#3
0
    def test_online_nodevice(self):
        '''
        Tests online
        '''
        ret = {}
        ret['stdout'] = ""
        ret['stderr'] = "cannot online /dev/rdsk/c0t0d1: no such device in pool"
        ret['retcode'] = 1
        mock_cmd = MagicMock(return_value=ret)

        with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \
             patch.dict(zpool.__utils__, utils_patch):
            ret = zpool.online('mypool', '/dev/rdsk/c0t0d1')
            res = OrderedDict([
                ('onlined', False),
                ('error', 'cannot online /dev/rdsk/c0t0d1: no such device in pool'),
            ])
            self.assertEqual(ret, res)
示例#4
0
    def test_online_nodevice(self):
        """
        Tests online
        """
        ret = {}
        ret["stdout"] = ""
        ret["stderr"] = "cannot online /dev/rdsk/c0t0d1: no such device in pool"
        ret["retcode"] = 1
        mock_cmd = MagicMock(return_value=ret)

        with patch.dict(zpool.__salt__, {"cmd.run_all": mock_cmd}), patch.dict(
                zpool.__utils__, self.utils_patch):
            ret = zpool.online("mypool", "/dev/rdsk/c0t0d1")
            res = OrderedDict([
                ("onlined", False),
                ("error",
                 "cannot online /dev/rdsk/c0t0d1: no such device in pool"),
            ])
            self.assertEqual(ret, res)