1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
"""Test intercepting a full module with interceptor."""
from uuid import uuid4
from httplib2 import Http
from wsgi_intercept.interceptor import Httplib2Interceptor
from .wsgi_app import simple_app
def app():
return simple_app
def setup_module(module):
module.host = str(uuid4())
module.intercept = Httplib2Interceptor(app, host=module.host)
module.intercept.install_intercept()
def teardown_module(module):
module.intercept.uninstall_intercept()
def test_simple_request():
global host
http = Http()
response, content = http.request('http://%s/' % host)
assert response.status == 200
assert 'WSGI intercept successful!' in content.decode('utf-8')
def test_another_request():
global host
http = Http()
response, content = http.request('http://%s/foobar' % host)
assert response.status == 200
assert 'WSGI intercept successful!' in content.decode('utf-8')
|