~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/code/interfaces/tests/test_branch.py

[r=Edwin][ui=None] BranchUpgradeJob refactoring for 2.0 changes,
        UI for requesting an upgrade.

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
from bzrlib.bzrdir import BzrDirFormat
12
12
from bzrlib.repository import format_registry as repo_format_registry
13
13
 
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
18
16
 
19
17
 
60
58
                            item.description)
61
59
 
62
60
 
63
 
class TestBranchFormatUpgradePath(TestCase):
64
 
    """Tests for BRANCH_FORMAT_UPGRADE_PATH."""
65
 
 
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)
71
 
 
72
 
 
73
 
class TestRepositoryFormatUpgradePath(TestCase):
74
 
    """Tests for BRANCH_FORMAT_UPGRADE_PATH."""
75
 
 
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:
80
 
            self.assertTrue(
81
 
                REPOSITORY_FORMAT_UPGRADE_PATH.has_key(format),
82
 
                "%r does not have a defined upgrade path." % format)
83
 
 
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:
90
 
                continue
91
 
            try:
92
 
                format_start = repo_format_registry.get(format.title)
93
 
            except KeyError: # We used a fake format string.
94
 
                continue
95
 
            format_end = repo_format_registry.get(
96
 
                upgrade_format().get_format_string())
97
 
            self.assertEqual(
98
 
                getattr(format_start, 'rich_root_data', False),
99
 
                getattr(format_end, 'rich_root_data', False))
100
 
            self.assertEqual(
101
 
                getattr(format_start, 'supports_tree_reference', False),
102
 
                getattr(format_end, 'supports_tree_reference', False))
103
 
 
104
 
 
105
61
def test_suite():
106
62
    return TestLoader().loadTestsFromName(__name__)