def test_write(self): ''' Test writing a specific attribute to a file ''' mock_cmd = MagicMock(return_value='squarepants') with patch.object(xattr, 'read', mock_cmd): self.assertTrue( xattr.write('/path/to/file', 'spongebob', 'squarepants'))
def test_write(): """ Test writing a specific attribute to a file """ mock_cmd = MagicMock(return_value="squarepants") with patch.object(xattr, "read", mock_cmd), patch( "salt.utils.mac_utils.execute_return_success", MagicMock(return_value=True)): assert xattr.write("/path/to/file", "spongebob", "squarepants")
def test_write(self): ''' Test writing a specific attribute to a file ''' mock_cmd = MagicMock(return_value='squarepants') with patch.object(xattr, 'read', mock_cmd): self.assertTrue(xattr.write('/path/to/file', 'spongebob', 'squarepants'))
def test_write(self): ''' Test writing a specific attribute to a file ''' mock_cmd = MagicMock(return_value='squarepants') with patch.object(xattr, 'read', mock_cmd), \ patch('salt.utils.mac_utils.execute_return_success', MagicMock(return_value=True)): self.assertTrue( xattr.write('/path/to/file', 'spongebob', 'squarepants'))
def test_write_attrs(self): ''' Test writing a specific attribute to a file ''' expected = "out" mock = MagicMock(return_value=expected) with patch.dict(xattr.__salt__, {'cmd.run': mock}): out = xattr.write('/path/to/file', 'com.attr', 'value') mock.assert_called_once_with('xattr -w "com.attr" "value" "/path/to/file"') self.assertEqual(out, expected)
def test_write_attrs(self): ''' Test writing a specific attribute to a file ''' expected = "out" mock = MagicMock(return_value=expected) with patch.dict(xattr.__salt__, {'cmd.run': mock}): out = xattr.write('/path/to/file', 'com.attr', 'value') mock.assert_called_once_with( 'xattr -w "com.attr" "value" "/path/to/file"') self.assertEqual(out, expected)