Projet

Général

Profil

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

Benjamin Dauvergne, 12 novembre 2015 10:11

Télécharger (2,63 ko)

Voir les différences:

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

 tests/test_publisher.py | 34 ++++++++++++++++++++++++++++++++++
 wcs/qommon/errors.py    |  5 ++++-
 2 files changed, 38 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
103
    req = HTTPRequest(StringIO.StringIO(''), {
104
        'SERVER_NAME': 'www.example.net',
105
        'SCRIPT_NAME': '',
106
        'PATH_INFO': '/gloubiboulga',
107
        'HTTP_ACCEPT_LANGUAGE': 'fr',
108
        })
109
    response = pub.process_request(req)
110
    assert '<p>The requested link' 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
    if getattr(exc, 'public_msg', None):
117
        return template.error_page(exc.format(), _(exc.title))
118
    else:
119
        return template.error_page(_(exc.description), _(exc.title))
117
-