~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/bugs/tests/test_apportjob.py

[rs=buildbot-poller] automatic merge from stable. Revisions: 14116,
        14117, 14118, 14119, 14120 included.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright 2010 Canonical Ltd.  This software is licensed under the
 
1
# Copyright 2010-2011 Canonical Ltd.  This software is licensed under the
2
2
# GNU Affero General Public License version 3 (see the file LICENSE).
3
3
 
4
4
"""Tests for ApportJobs."""
25
25
    )
26
26
from lp.bugs.interfaces.apportjob import (
27
27
    ApportJobType,
 
28
    IApportJob,
 
29
    IProcessApportBlobJob,
28
30
    IProcessApportBlobJobSource,
29
31
    )
30
32
from lp.bugs.model.apportjob import (
65
67
        # passed in.
66
68
        metadata_expected = [u'some', u'arbitrary', u'metadata']
67
69
        self.assertEqual(metadata_expected, apport_job.metadata)
 
70
        self.assertProvides(apport_job, IApportJob)
68
71
 
69
72
 
70
73
class ApportJobDerivedTestCase(TestCaseWithFactory):
95
98
        blob_data = blob_file.read()
96
99
 
97
100
        self.blob = self.factory.makeBlob(blob_data)
98
 
        transaction.commit() # We need the blob available from the Librarian.
 
101
        transaction.commit()  # We need the blob available from the Librarian.
99
102
 
100
103
    def _assertFileBugDataMatchesDict(self, filebug_data, data_dict):
101
104
        """Asser that the data in a FileBugData object matches a dict."""
173
176
                    "The attachment's file alias doesn't match it's "
174
177
                    "file_alias_id")
175
178
 
 
179
    def test_interface(self):
 
180
        # ProcessApportBlobJob instances provide IProcessApportBlobJobSource.
 
181
        job = getUtility(IProcessApportBlobJobSource).create(self.blob)
 
182
        self.assertProvides(job, IProcessApportBlobJob)
 
183
 
176
184
    def test_run(self):
177
185
        # IProcessApportBlobJobSource.run() extracts salient data from an
178
186
        # Apport BLOB and stores it in the job's metadata attribute.
237
245
            "There should be only one ProcessApportBlobJob. Found %s" %
238
246
            len(current_jobs))
239
247
 
240
 
        another_job = blobjobsource.create(self.blob)
 
248
        blobjobsource.create(self.blob)  # Another job.
241
249
        current_jobs = list(blobjobsource.iterReady())
242
250
        self.assertEqual(
243
251
            1, len(current_jobs),
366
374
 
367
375
        self.assertEqual(
368
376
            len(blob_meta['attachments']), 2,
369
 
            "BLOB metadata: %s" %(str(blob_meta)))
 
377
            "BLOB metadata: %s" % str(blob_meta))
370
378
 
371
379
    def test_adding_blob_adds_job(self):
372
380
        # Using the TemporaryBlobStorageAddView to upload a new BLOB