<s> from StringIO import StringIO <EOL> from mock import patch <EOL> from httmock import urlmatch , HTTMock <EOL> from nose . tools import eq_ <EOL> from acmd import get_tool , Server <EOL> CONTENT_RESPONSE = """<STR_LIT>""" <EOL> DIR_RESPONSE = """<STR_LIT>""" <EOL> PATH_RESPONSE = """<STR_LIT>""" <EOL> NODE_RESPONSE = """<STR_LIT>""" <EOL> @ urlmatch ( netloc = '<STR_LIT>' , method = '<STR_LIT:GET>' ) <EOL> def service_mock ( url , request ) : <EOL> if url . path == '<STR_LIT>' : <EOL> return CONTENT_RESPONSE <EOL> elif url . path == '<STR_LIT>' : <EOL> return PATH_RESPONSE <EOL> elif url . path == '<STR_LIT>' : <EOL> return DIR_RESPONSE <EOL> elif url . path == '<STR_LIT>' : <EOL> return NODE_RESPONSE <EOL> else : <EOL> raise Exception ( url . path ) <EOL> @ patch ( '<STR_LIT>' , new_callable = StringIO ) <EOL> @ patch ( '<STR_LIT>' , new_callable = StringIO ) <EOL> def test_cat ( stderr , stdout ) : <EOL> with HTTMock ( service_mock ) : <EOL> tool = get_tool ( '<STR_LIT>' ) <EOL> server = Server ( '<STR_LIT:localhost>' ) <EOL> status = tool . execute ( server , [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> eq_ ( <NUM_LIT:0> , status ) <EOL> eq_ ( '<STR_LIT>' , <EOL> stdout . getvalue ( ) ) <EOL> eq_ ( '<STR_LIT>' , stderr . getvalue ( ) ) <EOL> @ patch ( '<STR_LIT>' , new_callable = StringIO ) <EOL> @ patch ( '<STR_LIT>' , new_callable = StringIO ) <EOL> @ patch ( '<STR_LIT>' , new = StringIO ( '<STR_LIT>' ) ) <EOL> def test_cat_stdin ( stderr , stdout ) : <EOL> with HTTMock ( service_mock ) : <EOL> tool = get_tool ( '<STR_LIT>' ) <EOL> server = Server ( '<STR_LIT:localhost>' ) <EOL> status = tool . execute ( server , [ '<STR_LIT>' ] ) <EOL> eq_ ( <NUM_LIT:0> , status ) <EOL> eq_ ( '<STR_LIT>' , <EOL> stdout . getvalue ( ) ) <EOL> eq_ ( '<STR_LIT>' , stderr . getvalue ( ) ) </s>
