def test_list(self): """ Tests successful return of list function """ ret = {} ret["stdout"] = "mypool\t1.81T\t661G\t1.17T\t35%\t11%\tONLINE" 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.list_(parsable=False) res = OrderedDict( [ ( "mypool", OrderedDict( [ ("size", "1.81T"), ("alloc", "661G"), ("free", "1.17T"), ("cap", "35%"), ("frag", "11%"), ("health", "ONLINE"), ] ), ) ] ) self.assertEqual(ret, res)
def test_list_parsable(utils_patch): """ Tests successful return of list function with parsable output """ ret = {} ret["stdout"] = "mypool\t1.81T\t661G\t1.17T\t35%\t11%\tONLINE" 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__, utils_patch ): ret = zpool.list_(parsable=True) res = OrderedDict( [ ( "mypool", OrderedDict( [ ("size", 1990116046274), ("alloc", 709743345664), ("free", 1286428604497), ("cap", "35%"), ("frag", "11%"), ("health", "ONLINE"), ] ), ) ] ) assert ret == res
def test_list(self): ''' Tests successful return of list function ''' ret = {} ret['stdout'] = "mypool\t111G\t47.4G\t63.6G\t42%\tONLINE\n" ret['stderr'] = "" ret['retcode'] = 0 mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}): ret = zpool.list_() res = OrderedDict([('mypool', {'alloc': '47.4G', 'cap': '42%', 'free': '63.6G', 'health': 'ONLINE', 'size': '111G'})]) self.assertEqual(res, ret)
def test_list(self): ''' Tests successful return of list function ''' ret = {} ret['stdout'] = "mypool\t111G\t47.4G\t63.6G\t42%\tONLINE\n" ret['stderr'] = "" ret['retcode'] = 0 mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ patch('salt.modules.zpool._check_features', MagicMock(return_value=False)): ret = zpool.list_() res = OrderedDict([('mypool', {'alloc': '47.4G', 'cap': '42%', 'free': '63.6G', 'health': 'ONLINE', 'size': '111G'})]) self.assertEqual(res, ret)
def test_list_parsable(self): ''' Tests successful return of list function with parsable output ''' ret = {} ret['stdout'] = "mypool\t1992864825344\t767076794368\t1225788030976\t38\tONLINE" ret['stderr'] = "" ret['retcode'] = 0 mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ patch('salt.modules.zpool._check_features', MagicMock(return_value=False)): ret = zpool.list_() res = OrderedDict([('mypool', { 'alloc': 767076794368, 'cap': 38, 'free': 1225788030976, 'health': 'ONLINE', 'size': 1992864825344 })]) self.assertEqual(res, ret)
def test_list_parsable(self): ''' Tests successful return of list function with parsable output ''' ret = {} ret['stdout'] = "mypool\t1.81T\t661G\t1.17T\t35%\t11%\tONLINE" 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__, utils_patch): ret = zpool.list_(parsable=True) res = OrderedDict([('mypool', OrderedDict([ ('size', 1990116046274), ('alloc', 709743345664), ('free', 1286428604497), ('cap', '35%'), ('frag', '11%'), ('health', 'ONLINE'), ]))]) self.assertEqual(ret, res)
def test_list_parsable(self): ''' Tests successful return of list function with parsable output ''' ret = {} ret['stdout'] = "mypool\t1992864825344\t767076794368\t1225788030976\t38\t0%\tONLINE" 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__, utils_patch): ret = zpool.list_(parsable=True) res = OrderedDict([('mypool', OrderedDict([ ('size', 1992864825344), ('alloc', 767076794368), ('free', 1225788030976), ('cap', 38), ('frag', '0%'), ('health', 'ONLINE'), ]))]) self.assertEqual(ret, res)