1
# Copyright 2005-2011 Canonical Ltd. All rights reserved.
3
# This program is free software: you can redistribute it and/or modify
4
# it under the terms of the GNU Affero General Public License as published by
5
# the Free Software Foundation, either version 3 of the License, or
6
# (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU Affero General Public License for more details.
13
# You should have received a copy of the GNU Affero General Public License
14
# along with this program. If not, see <http://www.gnu.org/licenses/>.
17
from datetime import (
20
from cStringIO import StringIO
23
from testtools import TestCase
24
from testtools.matchers import Contains
26
from oopstools.oops.dbsummaries import WebAppErrorSummary
27
from oopstools.oops.models import parsed_oops_to_model_oops
30
class TestWebAppErrorSummary(TestCase):
32
def _createOops(self):
34
'id': 'OOPS-1234S101',
37
'value': u'a unicode char (\xa7)',
38
'time': datetime(2008, 1, 13, 23, 14, 23, 00, utc),
40
ignored = parsed_oops_to_model_oops(
41
python_oops, 'test_unicode_handling')
44
super(TestWebAppErrorSummary, self).setUp()
46
start = end = datetime(2008, 1, 13)
48
self.summary = WebAppErrorSummary(start, end, prefixes)
50
def test_renderHTML_with_unicode_data(self):
51
# Summarising an oops with a unicode exception value should output
52
# a UTF-8 encoded html representation.
54
self.summary.renderHTML(fp)
55
self.assertThat(fp.getvalue(), Contains('a unicode char (\xc2\xa7)'))