~lifeless/python-oops-tools/bug-881400

« back to all changes in this revision

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

  • Committer: Tarmac
  • Author(s): Robert Collins
  • Date: 2011-10-25 02:30:42 UTC
  • mfrom: (4.2.3 bug-879309)
  • Revision ID: launchpad@pqm.canonical.com-20111025023042-9h154ehut9sk7fbz
Handle unicode urls and missing topics better.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
    datetime,
20
20
    )
21
21
import os
 
22
import urllib
22
23
 
23
24
from fixtures import TempDir
24
25
from oops_datedir_repo.serializer_bson import write as write_bson
34
35
from oopstools.oops.models import (
35
36
    DBOopsRootDirectory,
36
37
    Oops,
 
38
    parsed_oops_to_model_oops,
37
39
    )
38
40
 
39
41
 
137
139
        loader = OopsLoader()
138
140
        list(loader.find_oopses(start_date))
139
141
        self.assertNotEqual(None, Oops.objects.get(oopsid='OOPS-123S202'))
 
142
 
 
143
 
 
144
class TestParsedToModel(TestCase):
 
145
 
 
146
    def test_url_handling(self):
 
147
        unicode_url = u'http://example.com/foo\u2019s asset'
 
148
        report = { 'url': unicode_url, 'id': 'testurlhandling'}
 
149
        expected_url = urllib.quote(unicode_url.encode('utf8'))
 
150
        oops = parsed_oops_to_model_oops(report, 'test_url_handling')
 
151
        self.assertEqual(expected_url, oops.url)
 
152
 
 
153
    def test_no_topic_pageid_empty_bug_880641(self):
 
154
        report = { 'url': 'foo', 'id': 'testnotopichandling'}
 
155
        oops = parsed_oops_to_model_oops(report, 'bug_880641')
 
156
        self.assertEqual('', oops.pageid)