~james-w/python-oops-tools/restfulclient-cert

« back to all changes in this revision

Viewing changes to src/oopstools/oops/test/test_dbsummaries.py

  • Committer: Tarmac
  • Author(s): Robert Collins
  • Date: 2012-09-11 03:01:01 UTC
  • mfrom: (39.1.1 bug-1048470)
  • Revision ID: launchpad@pqm.canonical.com-20120911030101-b3cvb3b6vrwethdu
Fix TXT reports for unicode pageids as well.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
    datetime,
19
19
    )
20
20
from cStringIO import StringIO
 
21
import uuid
21
22
 
22
23
from pytz import utc
23
24
from testtools import TestCase
31
32
 
32
33
    def _createOops(self):
33
34
        python_oops = {
34
 
            'id': 'OOPS-1234S101',
 
35
            'id': uuid.uuid4().get_hex(),
35
36
            'reporter': 'edge',
36
37
            'type': 'Exception',
37
38
            'value': u'a unicode char (\xa7)',
39
40
            'topic': u'more unicode \xa7',
40
41
            }
41
42
        ignored = parsed_oops_to_model_oops(
42
 
            python_oops, 'test_unicode_handling')
 
43
            python_oops, str(self.id()))
43
44
 
44
45
    def setUp(self):
45
46
        super(TestWebAppErrorSummary, self).setUp()
55
56
        self.summary.renderHTML(fp)
56
57
        self.assertThat(fp.getvalue(), Contains('a unicode char (\xc2\xa7)'))
57
58
        self.assertThat(fp.getvalue(), Contains('more unicode \xc2\xa7'))
 
59
 
 
60
    def test_renderTXT_with_unicode_data(self):
 
61
        # Summarising an oops with a unicode exception value should output
 
62
        # a UTF-8 encoded text representation.
 
63
        fp = StringIO()
 
64
        self.summary.renderTXT(fp)
 
65
        self.assertThat(fp.getvalue(), Contains('a unicode char (\xc2\xa7)'))
 
66
        self.assertThat(fp.getvalue(), Contains('more unicode \xc2\xa7'))