11
11
from bzrlib.bzrdir import BzrDirFormat
12
12
from bzrlib.repository import format_registry as repo_format_registry
14
from lp.code.bzr import (
15
BranchFormat, BRANCH_FORMAT_UPGRADE_PATH, ControlFormat, RepositoryFormat,
16
REPOSITORY_FORMAT_UPGRADE_PATH)
14
from lp.code.bzr import BranchFormat, ControlFormat, RepositoryFormat
17
15
from lp.testing import TestCase
63
class TestBranchFormatUpgradePath(TestCase):
64
"""Tests for BRANCH_FORMAT_UPGRADE_PATH."""
66
def test_branch_format_enum_as_keys(self):
67
# Each element of the BranchFormat enum should have a corresponding
68
# key in the BRANCH_FORMAT_UPGRADE_PATH dict.
69
for format in BranchFormat.items:
70
self.assertIn(format, BRANCH_FORMAT_UPGRADE_PATH)
73
class TestRepositoryFormatUpgradePath(TestCase):
74
"""Tests for BRANCH_FORMAT_UPGRADE_PATH."""
76
def test_repository_format_enum_as_keys(self):
77
# Each element of the BranchFormat enum should have a corresponding key
78
# in the BRANCH_FORMAT_UPGRADE_PATH dict.
79
for format in RepositoryFormat.items:
81
REPOSITORY_FORMAT_UPGRADE_PATH.has_key(format),
82
"%r does not have a defined upgrade path." % format)
84
def test_repository_format_upgrades_dont_cross_streams(self):
85
# Repository formats should not try to upgrade a format that doesn't
86
# support rich roots or subtrees to a format that does, and vice versa.
87
for format in REPOSITORY_FORMAT_UPGRADE_PATH.keys():
88
upgrade_format = REPOSITORY_FORMAT_UPGRADE_PATH[format]
89
if upgrade_format is None:
92
format_start = repo_format_registry.get(format.title)
93
except KeyError: # We used a fake format string.
95
format_end = repo_format_registry.get(
96
upgrade_format().get_format_string())
98
getattr(format_start, 'rich_root_data', False),
99
getattr(format_end, 'rich_root_data', False))
101
getattr(format_start, 'supports_tree_reference', False),
102
getattr(format_end, 'supports_tree_reference', False))
106
62
return TestLoader().loadTestsFromName(__name__)