Rev 5144: (Jelmer) Add per_bzrdir_colo tests. in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Mon Apr 12 01:26:48 BST 2010


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 5144 [merge]
revision-id: pqm at pqm.ubuntu.com-20100412002647-n2uymlq2ac1uf3rc
parent: pqm at pqm.ubuntu.com-20100410180354-4dft6p3nf7fvg50f
parent: jelmer at samba.org-20100411194548-6m09f6k6eugx596z
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Mon 2010-04-12 01:26:47 +0100
message:
  (Jelmer) Add per_bzrdir_colo tests.
added:
  bzrlib/tests/per_bzrdir_colo/  per_bzrdir_colo-20100411192232-kawv9qu1t42gv89k-1
  bzrlib/tests/per_bzrdir_colo/__init__.py __init__.py-20100411192232-kawv9qu1t42gv89k-2
  bzrlib/tests/per_bzrdir_colo/test_supported.py test_supported.py-20100411192232-kawv9qu1t42gv89k-3
  bzrlib/tests/per_bzrdir_colo/test_unsupported.py test_unsupported.py-20100411192232-kawv9qu1t42gv89k-4
modified:
  bzrlib/tests/__init__.py       selftest.py-20050531073622-8d0e3c8845c97a64
  bzrlib/tests/per_bzrdir/test_bzrdir.py test_bzrdir.py-20060131065642-0ebeca5e30e30866
=== modified file 'bzrlib/tests/__init__.py'
--- a/bzrlib/tests/__init__.py	2010-03-24 13:58:37 +0000
+++ b/bzrlib/tests/__init__.py	2010-04-11 19:40:23 +0000
@@ -3611,6 +3611,7 @@
         'bzrlib.tests.commands',
         'bzrlib.tests.per_branch',
         'bzrlib.tests.per_bzrdir',
+        'bzrlib.tests.per_bzrdir_colo',
         'bzrlib.tests.per_foreign_vcs',
         'bzrlib.tests.per_interrepository',
         'bzrlib.tests.per_intertree',

=== modified file 'bzrlib/tests/per_bzrdir/test_bzrdir.py'
--- a/bzrlib/tests/per_bzrdir/test_bzrdir.py	2010-03-02 22:25:58 +0000
+++ b/bzrlib/tests/per_bzrdir/test_bzrdir.py	2010-04-11 19:40:23 +0000
@@ -252,17 +252,6 @@
         bzrdir.create_branch()
         bzrdir.open_branch()
 
-    def test_destroy_colocated_branch(self):
-        branch = self.make_branch('branch')
-        bzrdir = branch.bzrdir
-        try:
-            colo_branch = bzrdir.create_branch('colo')
-        except errors.NoColocatedBranchSupport:
-            raise TestNotApplicable('BzrDir does not do colocated branches')
-        bzrdir.destroy_branch("colo")
-        self.assertRaises(errors.NotBranchError, bzrdir.open_branch, 
-                          "colo")
-
     def test_destroy_repository(self):
         repo = self.make_repository('repository')
         bzrdir = repo.bzrdir
@@ -1421,23 +1410,6 @@
         self.failUnless(isinstance(made_branch, bzrlib.branch.Branch))
         self.assertEqual(made_control, made_branch.bzrdir)
 
-    def test_create_colo_branch(self):
-        # a bzrdir can construct a branch and repository for itself.
-        if not self.bzrdir_format.is_supported():
-            # unsupported formats are not loopback testable
-            # because the default open will not open them and
-            # they may not be initializable.
-            raise TestNotApplicable('Control dir format not supported')
-        t = get_transport(self.get_url())
-        made_control = self.bzrdir_format.initialize(t.base)
-        made_repo = made_control.create_repository()
-        try:
-            made_branch = made_control.create_branch("colo")
-        except errors.NoColocatedBranchSupport:
-            raise TestNotApplicable('Colocated branches not supported')
-        self.failUnless(isinstance(made_branch, bzrlib.branch.Branch))
-        self.assertEqual(made_control, made_branch.bzrdir)
-
     def test_open_branch(self):
         if not self.bzrdir_format.is_supported():
             # unsupported formats are not loopback testable

=== added directory 'bzrlib/tests/per_bzrdir_colo'
=== added file 'bzrlib/tests/per_bzrdir_colo/__init__.py'
--- a/bzrlib/tests/per_bzrdir_colo/__init__.py	1970-01-01 00:00:00 +0000
+++ b/bzrlib/tests/per_bzrdir_colo/__init__.py	2010-04-11 19:40:23 +0000
@@ -0,0 +1,56 @@
+# Copyright (C) 2010 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
+
+
+"""Repository implementation tests for CHK support.
+
+These tests check the conformance of the chk index some repositories support.
+All repository formats are tested - those that do not suppport chk indices
+have the test_unsupported tests run; the others have the test_supported tests
+run.
+"""
+
+from bzrlib.bzrdir import BzrDirFormat
+from bzrlib.tests import (
+    default_transport,
+    multiply_tests,
+    )
+from bzrlib.tests.per_bzrdir import (
+    TestCaseWithBzrDir,
+    make_scenarios,
+    )
+
+
+def load_tests(standard_tests, module, loader):
+    colo_supported_formats = []
+    colo_unsupported_formats = []
+    for format in BzrDirFormat.known_formats():
+        if format.colocated_branches:
+            colo_supported_formats.append(format)
+        else:
+            colo_unsupported_formats.append(format)
+    supported_scenarios = make_scenarios(default_transport, None, None,
+        colo_supported_formats)
+    unsupported_scenarios = make_scenarios(default_transport, None, None,
+        colo_unsupported_formats)
+    result = loader.suiteClass()
+    supported_tests = loader.loadTestsFromModuleNames([
+        'bzrlib.tests.per_bzrdir_colo.test_supported'])
+    unsupported_tests = loader.loadTestsFromModuleNames([
+        'bzrlib.tests.per_bzrdir_colo.test_unsupported'])
+    multiply_tests(supported_tests, supported_scenarios, result)
+    multiply_tests(unsupported_tests, unsupported_scenarios, result)
+    return result

=== added file 'bzrlib/tests/per_bzrdir_colo/test_supported.py'
--- a/bzrlib/tests/per_bzrdir_colo/test_supported.py	1970-01-01 00:00:00 +0000
+++ b/bzrlib/tests/per_bzrdir_colo/test_supported.py	2010-04-11 19:45:48 +0000
@@ -0,0 +1,59 @@
+# Copyright (C) 2010 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 bzr directories that support colocated branches."""
+
+import bzrlib.branch
+from bzrlib import errors
+from bzrlib.tests import (
+    TestNotApplicable,
+    )
+from bzrlib.transport import (
+    get_transport,
+    )
+
+from bzrlib.tests.per_bzrdir_colo import (
+    TestCaseWithBzrDir,
+    )
+
+
+class TestColocatedBranchSupport(TestCaseWithBzrDir):
+
+    def test_destroy_colocated_branch(self):
+        branch = self.make_branch('branch')
+        bzrdir = branch.bzrdir
+        colo_branch = bzrdir.create_branch('colo')
+        bzrdir.destroy_branch("colo")
+        self.assertRaises(errors.NotBranchError, bzrdir.open_branch, 
+                          "colo")
+
+    def test_create_colo_branch(self):
+        # a bzrdir can construct a branch and repository for itself.
+        if not self.bzrdir_format.is_supported():
+            # unsupported formats are not loopback testable
+            # because the default open will not open them and
+            # they may not be initializable.
+            raise TestNotApplicable('Control dir format not supported')
+        t = get_transport(self.get_url())
+        try:
+            made_control = self.bzrdir_format.initialize(t.base)
+        except errors.UninitializableFormat:
+            raise TestNotApplicable('Control dir does not support creating '
+                'new branches.')
+        made_repo = made_control.create_repository()
+        made_branch = made_control.create_branch("colo")
+        self.failUnless(isinstance(made_branch, bzrlib.branch.Branch))
+        self.assertEqual(made_control, made_branch.bzrdir)

=== added file 'bzrlib/tests/per_bzrdir_colo/test_unsupported.py'
--- a/bzrlib/tests/per_bzrdir_colo/test_unsupported.py	1970-01-01 00:00:00 +0000
+++ b/bzrlib/tests/per_bzrdir_colo/test_unsupported.py	2010-04-11 19:40:23 +0000
@@ -0,0 +1,59 @@
+# Copyright (C) 2010 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 bazaar control directories that do not support colocated branches.
+
+Colocated branch support is optional, and when it is not supported the methods 
+and attributes colocated branch support added should fail in known ways.
+"""
+
+from bzrlib import errors
+from bzrlib.tests import (
+    TestNotApplicable,
+    )
+from bzrlib.transport import (
+    get_transport,
+    )
+
+from bzrlib.tests.per_bzrdir_colo import (
+    TestCaseWithBzrDir,
+    )
+
+
+class TestNoColocatedSupport(TestCaseWithBzrDir):
+
+    def test_destroy_colocated_branch(self):
+        branch = self.make_branch('branch')
+        # Colocated branches should not be supported *or* 
+        # destroy_branch should not be supported at all
+        self.assertRaises(
+            (errors.NoColocatedBranchSupport, errors.UnsupportedOperation),
+            branch.bzrdir.destroy_branch, 'colo')
+
+    def test_create_colo_branch(self):
+        # a bzrdir can construct a branch and repository for itself.
+        if not self.bzrdir_format.is_supported():
+            # unsupported formats are not loopback testable
+            # because the default open will not open them and
+            # they may not be initializable.
+            raise TestNotApplicable('Control dir format not supported')
+        t = get_transport(self.get_url())
+        made_control = self.bzrdir_format.initialize(t.base)
+        made_repo = made_control.create_repository()
+        self.assertRaises(errors.NoColocatedBranchSupport, 
+            made_control.create_branch, "colo")
+
+




More information about the bazaar-commits mailing list