Rev 3225: Start splitting the read and write parts of repository tests. in http://people.ubuntu.com/~robertc/baz2.0/shallow-branch
Robert Collins
robertc at robertcollins.net
Mon Feb 18 03:35:34 GMT 2008
At http://people.ubuntu.com/~robertc/baz2.0/shallow-branch
------------------------------------------------------------
revno: 3225
revision-id:robertc at robertcollins.net-20080218033518-opuvnwo2ng6mc2dy
parent: robertc at robertcollins.net-20080212051725-m8fjb5ouzl1pkso0
committer: Robert Collins <robertc at robertcollins.net>
branch nick: repository_implementations.split_read_write
timestamp: Mon 2008-02-18 14:35:18 +1100
message:
Start splitting the read and write parts of repository tests.
modified:
bzrlib/repository.py rev_storage.py-20051111201905-119e9401e46257e3
bzrlib/tests/repository_implementations/__init__.py __init__.py-20060131092037-9564957a7d4a841b
bzrlib/tests/repository_implementations/test_break_lock.py test_break_lock.py-20060504111704-ee09a107f9f42e43
=== modified file 'bzrlib/repository.py'
--- a/bzrlib/repository.py 2008-02-12 02:38:27 +0000
+++ b/bzrlib/repository.py 2008-02-18 03:35:18 +0000
@@ -2231,6 +2231,24 @@
"""
raise NotImplementedError(self.open)
+ def _make_test_read_instance(self, a_repository):
+ """Convert a_repository for reading from during tests.
+
+ This calls self._test_make_read_instance - a callable to convert a
+ writable repository type into one for performing reads on. This is
+ useful for test where:
+ - the repository type is not generally mutable, such as bundles
+ - testing external references, where the readable repository can just
+ be missing all the data.
+
+ This may involve copying data - if future changes are made to
+ a_repository, it should be converted again to ensure they are visible.
+
+ :param a_repository: The repository to convert.
+ :return: A repository.
+ """
+ return a_repository
+
class MetaDirRepositoryFormat(RepositoryFormat):
"""Common base class for the new repositories using the metadir layout."""
=== modified file 'bzrlib/tests/repository_implementations/__init__.py'
--- a/bzrlib/tests/repository_implementations/__init__.py 2008-01-11 03:54:51 +0000
+++ b/bzrlib/tests/repository_implementations/__init__.py 2008-02-18 03:35:18 +0000
@@ -79,6 +79,7 @@
"transport_readonly_server":self._transport_readonly_server,
"bzrdir_format":bzrdir_format,
"repository_format":repository_format,
+ "_make_test_read_instance":repository_format._make_test_read_instance,
})
# Only override the test's vfs_transport_factory if one was
# specified, otherwise just leave the default in place.
@@ -102,6 +103,10 @@
return super(TestCaseWithRepository, self).make_repository(
relpath, format=format)
+ def make_readable(self, a_repository):
+ """See RepositoryFormat._make_test_read_instance()."""
+ return self._make_test_read_instance(a_repository)
+
class BrokenRepoScenario(object):
"""Base class for defining scenarios for testing check and reconcile.
=== modified file 'bzrlib/tests/repository_implementations/test_break_lock.py'
--- a/bzrlib/tests/repository_implementations/test_break_lock.py 2007-10-17 09:39:41 +0000
+++ b/bzrlib/tests/repository_implementations/test_break_lock.py 2008-02-18 03:35:18 +0000
@@ -44,10 +44,16 @@
def test_unlocked(self):
# break lock when nothing is locked should just return
+ # direct
try:
self.repo.break_lock()
except NotImplementedError:
pass
+ # and on whatever readable version we are testing.
+ try:
+ self.make_readable(self.repo).break_lock()
+ except NotImplementedError:
+ pass
def test_locked(self):
# break_lock when locked should
More information about the bazaar-commits
mailing list