Files
deb-python-wsgi-intercept/wsgi_intercept/tests/test_module_interceptor.py
Chris Dent 4f9294ca2a Move tests from the test dir into wsgi_intercept/tests
This helps to insure the tests are included with the package
and to avoid conflicting with other packages.
2016-09-22 20:02:41 +01:00

39 lines
926 B
Python

"""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')