~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_revision.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-03-12 13:03:16 UTC
  • mfrom: (4119.4.5 bug-parsing)
  • Revision ID: pqm@pqm.ubuntu.com-20090312130316-vmqowmbcu2tzynem
(robertc) Add Revision.iter_bugs() method for getting bugs fixed by a
        revision. (Jonathan Lange)

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
import warnings
20
20
 
21
21
from bzrlib import (
 
22
    bugtracker,
22
23
    revision,
23
24
    symbol_versioning,
24
25
    )
25
26
from bzrlib.branch import Branch
26
 
from bzrlib.errors import NoSuchRevision
 
27
from bzrlib.errors import (
 
28
    InvalidBugStatus,
 
29
    InvalidLineInBugsProperty,
 
30
    NoSuchRevision,
 
31
    )
27
32
from bzrlib.deprecated_graph import Graph
28
33
from bzrlib.revision import (find_present_ancestors,
29
34
                             NULL_REVISION)
231
236
        self.assertEqual(['B'], r.get_apparent_authors())
232
237
        r.properties['authors'] = 'C\nD'
233
238
        self.assertEqual(['C', 'D'], r.get_apparent_authors())
 
239
 
 
240
 
 
241
class TestRevisionBugs(TestCase):
 
242
    """Tests for getting the bugs that a revision is linked to."""
 
243
 
 
244
    def test_no_bugs(self):
 
245
        r = revision.Revision('1')
 
246
        self.assertEqual([], list(r.iter_bugs()))
 
247
 
 
248
    def test_some_bugs(self):
 
249
        r = revision.Revision(
 
250
            '1', properties={
 
251
                'bugs': bugtracker.encode_fixes_bug_urls(
 
252
                    ['http://example.com/bugs/1',
 
253
                     'http://launchpad.net/bugs/1234'])})
 
254
        self.assertEqual(
 
255
            [('http://example.com/bugs/1', bugtracker.FIXED),
 
256
             ('http://launchpad.net/bugs/1234', bugtracker.FIXED)],
 
257
            list(r.iter_bugs()))
 
258
 
 
259
    def test_no_status(self):
 
260
        r = revision.Revision(
 
261
            '1', properties={'bugs': 'http://example.com/bugs/1'})
 
262
        self.assertRaises(InvalidLineInBugsProperty, list, r.iter_bugs())
 
263
 
 
264
    def test_too_much_information(self):
 
265
        r = revision.Revision(
 
266
            '1', properties={'bugs': 'http://example.com/bugs/1 fixed bar'})
 
267
        self.assertRaises(InvalidLineInBugsProperty, list, r.iter_bugs())
 
268
 
 
269
    def test_invalid_status(self):
 
270
        r = revision.Revision(
 
271
            '1', properties={'bugs': 'http://example.com/bugs/1 faxed'})
 
272
        self.assertRaises(InvalidBugStatus, list, r.iter_bugs())