~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_branch/test_branch.py

  • Committer: Patch Queue Manager
  • Date: 2011-10-10 17:21:12 UTC
  • mfrom: (6205.2.1 move-signature-tests)
  • Revision ID: pqm@pqm.ubuntu.com-20111010172112-zj6ufki2aonpr4ut
(jelmer) Move some signature-related tests from bzrlib.tests.per_branch to
 bzrlib.tests.per_repository. (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
253
253
                          self.get_branch().repository.get_revision,
254
254
                          None)
255
255
 
256
 
# TODO 20051003 RBC:
257
 
# compare the gpg-to-sign info for a commit with a ghost and
258
 
#     an identical tree without a ghost
259
 
# fetch missing should rewrite the TOC of weaves to list newly available parents.
260
 
 
261
 
    def test_sign_existing_revision(self):
262
 
        wt = self.make_branch_and_tree('.')
263
 
        branch = wt.branch
264
 
        wt.commit("base", allow_pointless=True, rev_id='A')
265
 
        from bzrlib.testament import Testament
266
 
        strategy = gpg.LoopbackGPGStrategy(None)
267
 
        branch.repository.lock_write()
268
 
        branch.repository.start_write_group()
269
 
        branch.repository.sign_revision('A', strategy)
270
 
        branch.repository.commit_write_group()
271
 
        branch.repository.unlock()
272
 
        self.assertEqual('-----BEGIN PSEUDO-SIGNED CONTENT-----\n' +
273
 
                         Testament.from_revision(branch.repository,
274
 
                         'A').as_short_text() +
275
 
                         '-----END PSEUDO-SIGNED CONTENT-----\n',
276
 
                         branch.repository.get_signature_text('A'))
277
 
 
278
 
    def test_store_signature(self):
279
 
        wt = self.make_branch_and_tree('.')
280
 
        branch = wt.branch
281
 
        branch.lock_write()
282
 
        try:
283
 
            branch.repository.start_write_group()
284
 
            try:
285
 
                branch.repository.store_revision_signature(
286
 
                    gpg.LoopbackGPGStrategy(None), 'FOO', 'A')
287
 
            except:
288
 
                branch.repository.abort_write_group()
289
 
                raise
290
 
            else:
291
 
                branch.repository.commit_write_group()
292
 
        finally:
293
 
            branch.unlock()
294
 
        # A signature without a revision should not be accessible.
295
 
        self.assertRaises(errors.NoSuchRevision,
296
 
                          branch.repository.has_signature_for_revision_id,
297
 
                          'A')
298
 
        wt.commit("base", allow_pointless=True, rev_id='A')
299
 
        self.assertEqual('-----BEGIN PSEUDO-SIGNED CONTENT-----\n'
300
 
                         'FOO-----END PSEUDO-SIGNED CONTENT-----\n',
301
 
                         branch.repository.get_signature_text('A'))
302
 
 
303
 
    def test_branch_keeps_signatures(self):
304
 
        wt = self.make_branch_and_tree('source')
305
 
        wt.commit('A', allow_pointless=True, rev_id='A')
306
 
        repo = wt.branch.repository
307
 
        repo.lock_write()
308
 
        repo.start_write_group()
309
 
        repo.sign_revision('A', gpg.LoopbackGPGStrategy(None))
310
 
        repo.commit_write_group()
311
 
        repo.unlock()
312
 
        #FIXME: clone should work to urls,
313
 
        # wt.clone should work to disks.
314
 
        self.build_tree(['target/'])
315
 
        d2 = repo.bzrdir.clone(urlutils.local_path_to_url('target'))
316
 
        self.assertEqual(repo.get_signature_text('A'),
317
 
                         d2.open_repository().get_signature_text('A'))
318
 
 
319
256
    def test_nicks_bzr(self):
320
257
        """Test the behaviour of branch nicks specific to bzr branches.
321
258