<s> import mock <EOL> from chef . fabric import chef_roledefs <EOL> from chef . tests import ChefTestCase , mockSearch <EOL> class FabricTestCase ( ChefTestCase ) : <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> def test_roledef ( self , MockSearch ) : <EOL> search_data = { <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) : { } , <EOL> } <EOL> search_mock_memo = { } <EOL> def search_mock ( index , q = '<STR_LIT>' , * args , ** kwargs ) : <EOL> data = search_data [ index , q ] <EOL> search_mock_inst = search_mock_memo . get ( ( index , q ) ) <EOL> if search_mock_inst is None : <EOL> search_mock_inst = search_mock_memo [ index , q ] = mock . Mock ( ) <EOL> search_mock_inst . data = data <EOL> return search_mock_inst <EOL> MockSearch . side_effect = search_mock <EOL> print ( MockSearch ( '<STR_LIT>' ) . data ) <EOL> @ mockSearch ( { ( '<STR_LIT>' , '<STR_LIT>' ) : { <NUM_LIT:1> : <NUM_LIT:2> } } ) <EOL> def test_roledef2 ( self , MockSearch ) : <EOL> print ( MockSearch ( '<STR_LIT>' ) . data ) </s>
