summaryrefslogtreecommitdiff
path: root/tests/test_errordocument.py
blob: fab7ccaa9ff1e62950d590e316a4e76934663197 (plain)
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
"""
Error Document Support Test
+++++++++++++++++++++++++++

WARNING: These tests aren't yet finished. A call to test_ok() using
not_found_app rather than simple_app currently fails complaining of
start_response not having been called before content is returned.

This isn't the full story since start_response will have been called
by the original response but I need advice on how to modify the 
test suite to be able to test this.

I also need to find out how to test that another response was
correctly requested by the middleware.
"""
import os
import py.test
from paste.errordocument import forward, custom_forward
from paste.fixture import *

def simple_app(environ, start_response):
    start_response("200 OK", [('Content-type', 'text/plain')])
    return ['requested page returned']

def not_found_app(environ, start_response):
    start_response("404 Not found", [('Content-type', 'text/plain')])
    return ['requested page returned']
    
def test_ok():
    app = TestApp(forward(simple_app, codes={404:'/error'}))
    res = app.get('')
    assert res.header('content-type') == 'text/plain'
    assert res.full_status == '200 OK'
    assert 'requested page returned' in res