Fix unit tests

This commit is contained in:
twangboy 2016-03-30 08:56:34 -06:00
parent 614b768d6a
commit 66afd4855c

View File

@ -76,7 +76,11 @@ class XAttrTestCase(TestCase):
'''
Test writing a specific attribute to a file
'''
self.assertTrue(xattr.write('/path/to/file', 'attribute', 'value'))
mock_cmd = MagicMock(return_value='squarepants')
with patch.object(xattr, 'read', mock_cmd):
self.assertTrue(xattr.write('/path/to/file',
'spongebob',
'squarepants'))
@patch('salt.utils.mac_utils.execute_return_success',
MagicMock(side_effect=CommandExecutionError('No such file')))
@ -96,6 +100,8 @@ class XAttrTestCase(TestCase):
'''
Test deleting a specific attribute from a file
'''
mock_cmd = MagicMock(return_value={'spongebob': 'squarepants'})
with patch.object(xattr, 'list', mock_cmd):
self.assertTrue(xattr.delete('/path/to/file', 'attribute'))
@patch('salt.utils.mac_utils.execute_return_success',
@ -115,6 +121,8 @@ class XAttrTestCase(TestCase):
'''
Test clearing all attributes on a file
'''
mock_cmd = MagicMock(return_value={})
with patch.object(xattr, 'list', mock_cmd):
self.assertTrue(xattr.clear('/path/to/file'))
@patch('salt.utils.mac_utils.execute_return_success',