~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_log.py

  • Committer: Vincent Ladeuil
  • Date: 2017-01-17 15:27:00 UTC
  • mfrom: (6619.2.1 1622039-diff-binaries)
  • mto: This revision was merged to the branch mainline in revision 6620.
  • Revision ID: v.ladeuil+lp@free.fr-20170117152700-d0l1z87gbbrlwdix
Merge bugfix for #1622039

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2011 Canonical Ltd
 
1
# Copyright (C) 2005-2013, 2016 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
25
25
    revision,
26
26
    revisionspec,
27
27
    tests,
 
28
    gpg,
 
29
    trace,
28
30
    )
29
31
 
30
32
 
281
283
        self.checkDelta(logentry.delta, added=['file1', 'file2'])
282
284
 
283
285
 
 
286
class TestFormatSignatureValidity(tests.TestCaseWithTransport):
 
287
    class UTFLoopbackGPGStrategy(gpg.LoopbackGPGStrategy):
 
288
        def verify(self, content, testament):
 
289
            return (gpg.SIGNATURE_VALID,
 
290
                u'UTF8 Test \xa1\xb1\xc1\xd1\xe1\xf1 <jrandom@example.com>')
 
291
 
 
292
    def has_signature_for_revision_id(self, revision_id):
 
293
        return True
 
294
 
 
295
    def get_signature_text(self, revision_id):
 
296
        return ''
 
297
 
 
298
    def test_format_signature_validity_utf(self):
 
299
        """Check that GPG signatures containing UTF-8 names are formatted
 
300
        correctly."""
 
301
        # Monkey patch to use our UTF-8 generating GPGStrategy
 
302
        self.overrideAttr(gpg, 'GPGStrategy', self.UTFLoopbackGPGStrategy)
 
303
        wt = self.make_branch_and_tree('.')
 
304
        revid = wt.commit('empty commit')
 
305
        repo = wt.branch.repository
 
306
        # Monkey patch out checking if this rev is actually signed, since we
 
307
        # can't sign it without a heavier TestCase and LoopbackGPGStrategy
 
308
        # doesn't care anyways.
 
309
        self.overrideAttr(repo, 'has_signature_for_revision_id',
 
310
                self.has_signature_for_revision_id)
 
311
        self.overrideAttr(repo, 'get_signature_text', self.get_signature_text)
 
312
        out = log.format_signature_validity(revid, repo)
 
313
        self.assertEqual(
 
314
u'valid signature from UTF8 Test \xa1\xb1\xc1\xd1\xe1\xf1 <jrandom@example.com>',
 
315
                out)
 
316
 
 
317
 
284
318
class TestShortLogFormatter(TestCaseForLogFormatter):
285
319
 
286
320
    def test_trailing_newlines(self):
1309
1343
class TestLogWithBugs(TestCaseForLogFormatter, TestLogMixin):
1310
1344
 
1311
1345
    def setUp(self):
1312
 
        TestCaseForLogFormatter.setUp(self)
 
1346
        super(TestLogWithBugs, self).setUp()
1313
1347
        log.properties_handler_registry.register(
1314
1348
            'bugs_properties_handler',
1315
1349
            log._bugs_properties_handler)
1389
1423
class TestLogForAuthors(TestCaseForLogFormatter):
1390
1424
 
1391
1425
    def setUp(self):
1392
 
        TestCaseForLogFormatter.setUp(self)
 
1426
        super(TestLogForAuthors, self).setUp()
1393
1427
        self.wt = self.make_standard_commit('nicky',
1394
1428
            authors=['John Doe <jdoe@example.com>',
1395
1429
                     'Jane Rey <jrey@example.com>'])
1626
1660
        request = log.make_log_request_dict(limit=10)
1627
1661
        log.Logger(b, request).show(log_formatter)
1628
1662
        # should have all three revisions:
1629
 
        self.assertEquals(len(log_formatter.revisions), 3)
 
1663
        self.assertEqual(len(log_formatter.revisions), 3)
1630
1664
 
1631
1665
        del log_formatter
1632
1666
        log_formatter = LogCatcher()
1634
1668
        request = log.make_log_request_dict(limit=10, levels=1)
1635
1669
        log.Logger(b, request).show(log_formatter)
1636
1670
        # should now only have 2 revisions:
1637
 
        self.assertEquals(len(log_formatter.revisions), 2)
 
1671
        self.assertEqual(len(log_formatter.revisions), 2)
1638
1672