<s> from . import AppEngineSandboxTest , MockResponse <EOL> from mock import patch <EOL> from nose . plugins . skip import SkipTest <EOL> from . . test_no_ssl import TestWithoutSSL <EOL> class TestHTTP ( AppEngineSandboxTest , TestWithoutSSL ) : <EOL> nosegae_urlfetch = True <EOL> def test_urlfetch_called_with_http ( self ) : <EOL> """<STR_LIT>""" <EOL> resp = MockResponse ( <EOL> '<STR_LIT:OK>' , <EOL> <NUM_LIT:200> , <EOL> False , <EOL> '<STR_LIT>' , <EOL> { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> with patch ( '<STR_LIT>' , return_value = resp ) as fetchmock : <EOL> import urllib3 <EOL> pool = urllib3 . HTTPConnectionPool ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> r = pool . request ( '<STR_LIT:GET>' , '<STR_LIT:/>' ) <EOL> self . assertEqual ( r . status , <NUM_LIT:200> , r . data ) <EOL> self . assertEqual ( fetchmock . call_count , <NUM_LIT:1> ) <EOL> class TestHTTPS ( AppEngineSandboxTest ) : <EOL> nosegae_urlfetch = True <EOL> def test_urlfetch_called_with_https ( self ) : <EOL> """<STR_LIT>""" <EOL> raise SkipTest ( ) <EOL> resp = MockResponse ( <EOL> '<STR_LIT:OK>' , <EOL> <NUM_LIT:200> , <EOL> False , <EOL> '<STR_LIT>' , <EOL> { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> with patch ( '<STR_LIT>' , return_value = resp ) as fetchmock : <EOL> import urllib3 <EOL> pool = urllib3 . HTTPSConnectionPool ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> pool . ConnectionCls = urllib3 . connection . UnverifiedHTTPSConnection <EOL> r = pool . request ( '<STR_LIT:GET>' , '<STR_LIT:/>' ) <EOL> self . assertEqual ( r . status , <NUM_LIT:200> , r . data ) <EOL> self . assertEqual ( fetchmock . call_count , <NUM_LIT:1> ) </s>
