~bzr/ubuntu/lucid/bzr/beta-ppa

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_re_sign.py

  • Committer: Martin Pool
  • Date: 2010-08-18 04:26:39 UTC
  • mfrom: (129.1.8 packaging-karmic)
  • Revision ID: mbp@sourcefrog.net-20100818042639-mjoxtngyjwiu05fo
* PPA rebuild for lucid.
* PPA rebuild for karmic.
* PPA rebuild onto jaunty.
* New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005 Canonical Ltd
 
1
# Copyright (C) 2005-2010 Canonical Ltd
2
2
# -*- coding: utf-8 -*-
3
3
#
4
4
# This program is free software; you can redistribute it and/or modify
21
21
 
22
22
import os
23
23
 
24
 
import bzrlib.gpg
 
24
from bzrlib import (
 
25
    gpg,
 
26
    tests,
 
27
    )
25
28
from bzrlib.bzrdir import BzrDir
26
29
from bzrlib.testament import Testament
27
 
from bzrlib.tests import TestCaseInTempDir
28
 
 
29
 
 
30
 
class ReSign(TestCaseInTempDir):
 
30
 
 
31
 
 
32
class ReSign(tests.TestCaseInTempDir):
31
33
 
32
34
    def monkey_patch_gpg(self):
33
35
        """Monkey patch the gpg signing strategy to be a loopback.
35
37
        This also registers the cleanup, so that we will revert to
36
38
        the original gpg strategy when done.
37
39
        """
38
 
        self._oldstrategy = bzrlib.gpg.GPGStrategy
39
 
 
40
40
        # monkey patch gpg signing mechanism
41
 
        bzrlib.gpg.GPGStrategy = bzrlib.gpg.LoopbackGPGStrategy
42
 
 
43
 
        self.addCleanup(self._fix_gpg_strategy)
44
 
 
45
 
    def _fix_gpg_strategy(self):
46
 
        bzrlib.gpg.GPGStrategy = self._oldstrategy
 
41
        self.overrideAttr(gpg, 'GPGStrategy', gpg.LoopbackGPGStrategy)
47
42
 
48
43
    def setup_tree(self):
49
44
        wt = BzrDir.create_standalone_workingtree('.')
93
88
        self.assertEqualSignature(repo, 'A')
94
89
        self.assertEqualSignature(repo, 'B')
95
90
        self.assertEqualSignature(repo, 'C')
 
91
 
 
92
    def test_resign_directory(self):
 
93
        """Test --directory option"""
 
94
        wt = BzrDir.create_standalone_workingtree('a')
 
95
        wt.commit("base A", allow_pointless=True, rev_id='A')
 
96
        wt.commit("base B", allow_pointless=True, rev_id='B')
 
97
        wt.commit("base C", allow_pointless=True, rev_id='C')
 
98
        repo = wt.branch.repository
 
99
        self.monkey_patch_gpg()
 
100
        self.run_bzr('re-sign --directory=a -r revid:A')
 
101
        self.assertEqualSignature(repo, 'A')
 
102
        self.run_bzr('re-sign -d a B')
 
103
        self.assertEqualSignature(repo, 'B')