Rev 6207: (jelmer) Move some signature-related tests from bzrlib.tests.per_branch to in file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/

Patch Queue Manager pqm at pqm.ubuntu.com
Mon Oct 10 17:21:12 UTC 2011


At file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 6207 [merge]
revision-id: pqm at pqm.ubuntu.com-20111010172112-zj6ufki2aonpr4ut
parent: pqm at pqm.ubuntu.com-20111010142604-n77hphh9k3lfn668
parent: jelmer at samba.org-20111010140332-kgf85hqk4v1us9yd
committer: Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Mon 2011-10-10 17:21:12 +0000
message:
  (jelmer) Move some signature-related tests from bzrlib.tests.per_branch to
   bzrlib.tests.per_repository. (Jelmer Vernooij)
added:
  bzrlib/tests/per_repository/test_signatures.py test_signatures.py-20111010140248-mdiotjn81vw9p7yb-1
modified:
  bzrlib/tests/per_branch/test_branch.py testbranch.py-20050711070244-121d632bc37d7253
  bzrlib/tests/per_repository/__init__.py __init__.py-20060131092037-9564957a7d4a841b
=== modified file 'bzrlib/tests/per_branch/test_branch.py'
--- a/bzrlib/tests/per_branch/test_branch.py	2011-10-04 15:04:29 +0000
+++ b/bzrlib/tests/per_branch/test_branch.py	2011-10-10 14:03:32 +0000
@@ -253,69 +253,6 @@
                           self.get_branch().repository.get_revision,
                           None)
 
-# TODO 20051003 RBC:
-# compare the gpg-to-sign info for a commit with a ghost and
-#     an identical tree without a ghost
-# fetch missing should rewrite the TOC of weaves to list newly available parents.
-
-    def test_sign_existing_revision(self):
-        wt = self.make_branch_and_tree('.')
-        branch = wt.branch
-        wt.commit("base", allow_pointless=True, rev_id='A')
-        from bzrlib.testament import Testament
-        strategy = gpg.LoopbackGPGStrategy(None)
-        branch.repository.lock_write()
-        branch.repository.start_write_group()
-        branch.repository.sign_revision('A', strategy)
-        branch.repository.commit_write_group()
-        branch.repository.unlock()
-        self.assertEqual('-----BEGIN PSEUDO-SIGNED CONTENT-----\n' +
-                         Testament.from_revision(branch.repository,
-                         'A').as_short_text() +
-                         '-----END PSEUDO-SIGNED CONTENT-----\n',
-                         branch.repository.get_signature_text('A'))
-
-    def test_store_signature(self):
-        wt = self.make_branch_and_tree('.')
-        branch = wt.branch
-        branch.lock_write()
-        try:
-            branch.repository.start_write_group()
-            try:
-                branch.repository.store_revision_signature(
-                    gpg.LoopbackGPGStrategy(None), 'FOO', 'A')
-            except:
-                branch.repository.abort_write_group()
-                raise
-            else:
-                branch.repository.commit_write_group()
-        finally:
-            branch.unlock()
-        # A signature without a revision should not be accessible.
-        self.assertRaises(errors.NoSuchRevision,
-                          branch.repository.has_signature_for_revision_id,
-                          'A')
-        wt.commit("base", allow_pointless=True, rev_id='A')
-        self.assertEqual('-----BEGIN PSEUDO-SIGNED CONTENT-----\n'
-                         'FOO-----END PSEUDO-SIGNED CONTENT-----\n',
-                         branch.repository.get_signature_text('A'))
-
-    def test_branch_keeps_signatures(self):
-        wt = self.make_branch_and_tree('source')
-        wt.commit('A', allow_pointless=True, rev_id='A')
-        repo = wt.branch.repository
-        repo.lock_write()
-        repo.start_write_group()
-        repo.sign_revision('A', gpg.LoopbackGPGStrategy(None))
-        repo.commit_write_group()
-        repo.unlock()
-        #FIXME: clone should work to urls,
-        # wt.clone should work to disks.
-        self.build_tree(['target/'])
-        d2 = repo.bzrdir.clone(urlutils.local_path_to_url('target'))
-        self.assertEqual(repo.get_signature_text('A'),
-                         d2.open_repository().get_signature_text('A'))
-
     def test_nicks_bzr(self):
         """Test the behaviour of branch nicks specific to bzr branches.
 

=== modified file 'bzrlib/tests/per_repository/__init__.py'
--- a/bzrlib/tests/per_repository/__init__.py	2011-10-09 13:57:09 +0000
+++ b/bzrlib/tests/per_repository/__init__.py	2011-10-10 14:03:32 +0000
@@ -128,6 +128,7 @@
         'test_refresh_data',
         'test_repository',
         'test_revision',
+        'test_signatures',
         'test_statistics',
         'test_write_group',
         ]

=== added file 'bzrlib/tests/per_repository/test_signatures.py'
--- a/bzrlib/tests/per_repository/test_signatures.py	1970-01-01 00:00:00 +0000
+++ b/bzrlib/tests/per_repository/test_signatures.py	2011-10-10 14:03:32 +0000
@@ -0,0 +1,95 @@
+# Copyright (C) 2005-2011 Canonical Ltd
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+"""Tests for repository revision signatures."""
+
+from bzrlib import (
+    errors,
+    gpg,
+    tests,
+    urlutils,
+    )
+
+from bzrlib.testament import Testament
+from bzrlib.tests import per_repository
+
+class TestSignatures(per_repository.TestCaseWithRepository):
+
+# TODO 20051003 RBC:
+# compare the gpg-to-sign info for a commit with a ghost and
+#     an identical tree without a ghost
+# fetch missing should rewrite the TOC of weaves to list newly available parents.
+
+    def test_sign_existing_revision(self):
+        wt = self.make_branch_and_tree('.')
+        wt.commit("base", allow_pointless=True, rev_id='A')
+        strategy = gpg.LoopbackGPGStrategy(None)
+        repo = wt.branch.repository
+        self.addCleanup(repo.lock_write().unlock)
+        repo.start_write_group()
+        repo.sign_revision('A', strategy)
+        repo.commit_write_group()
+        self.assertEqual('-----BEGIN PSEUDO-SIGNED CONTENT-----\n' +
+                         Testament.from_revision(repo,
+                         'A').as_short_text() +
+                         '-----END PSEUDO-SIGNED CONTENT-----\n',
+                         repo.get_signature_text('A'))
+
+    def test_store_signature(self):
+        wt = self.make_branch_and_tree('.')
+        branch = wt.branch
+        branch.lock_write()
+        try:
+            branch.repository.start_write_group()
+            try:
+                branch.repository.store_revision_signature(
+                    gpg.LoopbackGPGStrategy(None), 'FOO', 'A')
+            except errors.NoSuchRevision:
+                branch.repository.abort_write_group()
+                raise tests.TestNotApplicable(
+                    "repository does not support signing non-present"
+                    "revisions")
+            except:
+                branch.repository.abort_write_group()
+                raise
+            else:
+                branch.repository.commit_write_group()
+        finally:
+            branch.unlock()
+        # A signature without a revision should not be accessible.
+        self.assertRaises(errors.NoSuchRevision,
+                          branch.repository.has_signature_for_revision_id,
+                          'A')
+        wt.commit("base", allow_pointless=True, rev_id='A')
+        self.assertEqual('-----BEGIN PSEUDO-SIGNED CONTENT-----\n'
+                         'FOO-----END PSEUDO-SIGNED CONTENT-----\n',
+                         branch.repository.get_signature_text('A'))
+
+    def test_clone_preserves_signatures(self):
+        wt = self.make_branch_and_tree('source')
+        wt.commit('A', allow_pointless=True, rev_id='A')
+        repo = wt.branch.repository
+        repo.lock_write()
+        repo.start_write_group()
+        repo.sign_revision('A', gpg.LoopbackGPGStrategy(None))
+        repo.commit_write_group()
+        repo.unlock()
+        #FIXME: clone should work to urls,
+        # wt.clone should work to disks.
+        self.build_tree(['target/'])
+        d2 = repo.bzrdir.clone(urlutils.local_path_to_url('target'))
+        self.assertEqual(repo.get_signature_text('A'),
+                         d2.open_repository().get_signature_text('A'))




More information about the bazaar-commits mailing list