File: test_module_interceptor.py

package info (click to toggle)
python-wsgi-intercept 1.13.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 560 kB
  • sloc: python: 1,390; makefile: 56; sh: 5
file content (38 lines) | stat: -rw-r--r-- 926 bytes parent folder | download | duplicates (4)
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')