<s> from __future__ import absolute_import <EOL> from salttesting import TestCase <EOL> from salttesting . helpers import ensure_in_syspath <EOL> from salttesting . mock import MagicMock , patch <EOL> ensure_in_syspath ( '<STR_LIT>' ) <EOL> from salt . exceptions import CommandExecutionError <EOL> from salt . modules import mac_xattr as xattr <EOL> import salt . utils . mac_utils <EOL> xattr . __salt__ = { } <EOL> class XAttrTestCase ( TestCase ) : <EOL> @ patch ( '<STR_LIT>' , <EOL> MagicMock ( return_value = '<STR_LIT>' ) ) <EOL> def test_list ( self ) : <EOL> '''<STR_LIT>''' <EOL> expected = { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } <EOL> with patch . object ( xattr , '<STR_LIT>' , MagicMock ( side_effect = [ '<STR_LIT>' , <EOL> '<STR_LIT>' ] ) ) : <EOL> self . assertEqual ( xattr . list ( '<STR_LIT>' ) , expected ) <EOL> @ patch ( '<STR_LIT>' , <EOL> MagicMock ( side_effect = CommandExecutionError ( '<STR_LIT>' ) ) ) <EOL> def test_list_missing ( self ) : <EOL> '''<STR_LIT>''' <EOL> self . assertRaises ( CommandExecutionError , xattr . list , '<STR_LIT>' ) <EOL> @ patch ( '<STR_LIT>' , <EOL> MagicMock ( return_value = '<STR_LIT>' ) ) <EOL> def test_read ( self ) : <EOL> '''<STR_LIT>''' <EOL> self . assertEqual ( xattr . read ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> '<STR_LIT>' ) <EOL> def test_read_hex ( self ) : <EOL> '''<STR_LIT>''' <EOL> with patch . object ( salt . utils . mac_utils , '<STR_LIT>' , <EOL> MagicMock ( return_value = '<STR_LIT>' ) ) as mock : <EOL> self . assertEqual ( xattr . read ( '<STR_LIT>' , '<STR_LIT>' , True ) , <EOL> '<STR_LIT>' ) <EOL> mock . assert_called_once_with ( '<STR_LIT>' ) <EOL> @ patch ( '<STR_LIT>' , <EOL> MagicMock ( side_effect = CommandExecutionError ( '<STR_LIT>' ) ) ) <EOL> def test_read_missing ( self ) : <EOL> '''<STR_LIT>''' <EOL> self . assertRaises ( CommandExecutionError , <EOL> xattr . read , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ) <EOL> @ patch ( '<STR_LIT>' , <EOL> MagicMock ( return_value = True ) ) <EOL> def test_write ( self ) : <EOL> '''<STR_LIT>''' <EOL> mock_cmd = MagicMock ( return_value = '<STR_LIT>' ) <EOL> with patch . object ( xattr , '<STR_LIT>' , mock_cmd ) : <EOL> self . assertTrue ( xattr . write ( '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ) ) <EOL> @ patch ( '<STR_LIT>' , <EOL> MagicMock ( side_effect = CommandExecutionError ( '<STR_LIT>' ) ) ) <EOL> def test_write_missing ( self ) : <EOL> '''<STR_LIT>''' <EOL> self . assertRaises ( CommandExecutionError , <EOL> xattr . write , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT:value>' ) <EOL> @ patch ( '<STR_LIT>' , <EOL> MagicMock ( return_value = True ) ) <EOL> def test_delete ( self ) : <EOL> '''<STR_LIT>''' <EOL> mock_cmd = MagicMock ( return_value = { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> with patch . object ( xattr , '<STR_LIT:list>' , mock_cmd ) : <EOL> self . assertTrue ( xattr . delete ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> @ patch ( '<STR_LIT>' , <EOL> MagicMock ( side_effect = CommandExecutionError ( '<STR_LIT>' ) ) ) <EOL> def test_delete_missing ( self ) : <EOL> '''<STR_LIT>''' <EOL> self . assertRaises ( CommandExecutionError , <EOL> xattr . delete , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ) <EOL> @ patch ( '<STR_LIT>' , <EOL> MagicMock ( return_value = True ) ) <EOL> def test_clear ( self ) : <EOL> '''<STR_LIT>''' <EOL> mock_cmd = MagicMock ( return_value = { } ) <EOL> with patch . object ( xattr , '<STR_LIT:list>' , mock_cmd ) : <EOL> self . assertTrue ( xattr . clear ( '<STR_LIT>' ) ) <EOL> @ patch ( '<STR_LIT>' , <EOL> MagicMock ( side_effect = CommandExecutionError ( '<STR_LIT>' ) ) ) <EOL> def test_clear_missing ( self ) : <EOL> '''<STR_LIT>''' <EOL> self . assertRaises ( CommandExecutionError , xattr . clear , '<STR_LIT>' ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> from integration import run_tests <EOL> run_tests ( XAttrTestCase , needs_daemon = False ) </s>
