<s> '''<STR_LIT>''' <EOL> from __future__ import absolute_import <EOL> from salttesting import skipIf , TestCase <EOL> from salttesting . mock import ( <EOL> NO_MOCK , <EOL> NO_MOCK_REASON , <EOL> MagicMock , <EOL> patch ) <EOL> from salttesting . helpers import ensure_in_syspath <EOL> ensure_in_syspath ( '<STR_LIT>' ) <EOL> from salt . modules import raet_publish <EOL> import salt . transport <EOL> from salt . exceptions import SaltReqTimeoutError <EOL> raet_publish . __opts__ = { } <EOL> @ skipIf ( NO_MOCK , NO_MOCK_REASON ) <EOL> class RaetPublishTestCase ( TestCase ) : <EOL> '''<STR_LIT>''' <EOL> def test_publish ( self ) : <EOL> '''<STR_LIT>''' <EOL> with patch . object ( raet_publish , '<STR_LIT>' , return_value = '<STR_LIT:A>' ) : <EOL> self . assertEqual ( raet_publish . publish ( '<STR_LIT>' , '<STR_LIT>' ) , '<STR_LIT:A>' ) <EOL> def test_full_data ( self ) : <EOL> '''<STR_LIT>''' <EOL> with patch . object ( raet_publish , '<STR_LIT>' , return_value = '<STR_LIT:A>' ) : <EOL> self . assertEqual ( raet_publish . full_data ( '<STR_LIT>' , '<STR_LIT>' ) , '<STR_LIT:A>' ) <EOL> def test_runner ( self ) : <EOL> '''<STR_LIT>''' <EOL> with patch . dict ( raet_publish . __opts__ , { '<STR_LIT:id>' : '<STR_LIT:id>' } ) : <EOL> with patch . object ( salt . transport . Channel , '<STR_LIT>' , MagicMock ( ) ) : <EOL> self . assertTrue ( raet_publish . runner ( '<STR_LIT>' ) ) <EOL> class MockFactory ( object ) : <EOL> '''<STR_LIT>''' <EOL> load = '<STR_LIT>' <EOL> def send ( self , load ) : <EOL> '''<STR_LIT>''' <EOL> self . load = load <EOL> raise SaltReqTimeoutError ( load ) <EOL> with patch . dict ( raet_publish . __opts__ , { '<STR_LIT:id>' : '<STR_LIT:id>' } ) : <EOL> with patch . object ( salt . transport . Channel , '<STR_LIT>' , <EOL> MagicMock ( return_value = MockFactory ( ) ) ) : <EOL> self . assertEqual ( raet_publish . runner ( <NUM_LIT:1> ) , <EOL> '<STR_LIT>' ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> from integration import run_tests <EOL> run_tests ( RaetPublishTestCase , needs_daemon = False ) </s>
