Projet

Général

Profil

0001-Show-public_msg-on-PublishError-error-page-8944.patch

Benjamin Dauvergne, 11 novembre 2015 13:45

Télécharger (2,2 ko)

Voir les différences:

Subject: [PATCH] Show public_msg on PublishError error page (#8944)

 tests/test_publisher.py | 26 ++++++++++++++++++++++++++
 wcs/qommon/errors.py    |  2 +-
 2 files changed, 27 insertions(+), 1 deletion(-)
tests/test_publisher.py
1 1
import re
2 2
import sys
3 3
import shutil
4
import StringIO
4 5

  
5 6
from quixote import cleanup
6 7
from wcs.qommon.http_request import HTTPRequest
......
74 75
        body = pub.finish_failed_request()
75 76
        assert 'Traceback (most recent call last)' in str(body)
76 77
        assert '<div class="error-page">' in str(body)
78

  
79
def test_finish_interrupted_request():
80
    req = HTTPRequest(StringIO.StringIO(''), {
81
        'SERVER_NAME': 'www.example.net',
82
        'SCRIPT_NAME': '',
83
        'CONTENT_LENGTH': 'aaa',
84
        })
85
    response = pub.process_request(req)
86
    assert 'invalid content-length header' in response.body
87
    req = HTTPRequest(StringIO.StringIO(''), {
88
        'SERVER_NAME': 'www.example.net',
89
        'SCRIPT_NAME': '',
90
        'CONTENT_TYPE': 'application/x-www-form-urlencoded',
91
        'CONTENT_LENGTH': '1',
92
        })
93
    response = pub.process_request(req)
94
    assert 'Invalid request: unexpected end of request body' in response.body
95
    req = HTTPRequest(StringIO.StringIO(''), {
96
        'SERVER_NAME': 'www.example.net',
97
        'SCRIPT_NAME': '',
98
        'CONTENT_TYPE': 'multipart/form-data',
99
        'CONTENT_LENGTH': '1',
100
        })
101
    response = pub.process_request(req)
102
    assert 'Invalid request: multipart/form-data missing boundary' in response.body
wcs/qommon/errors.py
113 113

  
114 114

  
115 115
def format_publish_error(exc):
116
    return template.error_page(_(exc.description), _(exc.title))
116
    return template.error_page(exc.format(), _(exc.title))
117
-