~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_upgrade_stacked.py

  • Committer: John Arbash Meinel
  • Author(s): Mark Hammond
  • Date: 2008-09-09 17:02:21 UTC
  • mto: This revision was merged to the branch mainline in revision 3697.
  • Revision ID: john@arbash-meinel.com-20080909170221-svim3jw2mrz0amp3
An updated transparent icon for bzr.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2008, 2009, 2011 Canonical Ltd
 
1
# Copyright (C) 2008 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
 
18
18
"""Tests for upgrades of various stacking situations."""
19
19
 
20
20
from bzrlib import (
21
 
    controldir,
22
 
    check,
 
21
    bzrdir,
23
22
    errors,
24
23
    tests,
25
24
    )
26
25
from bzrlib.upgrade import upgrade
27
 
from bzrlib.tests.scenarios import load_tests_apply_scenarios
28
 
 
29
 
 
30
 
def upgrade_scenarios():
31
 
    scenario_pairs = [ # old format, new format, model_change
32
 
#        ('knit', 'rich-root', True),
33
 
        ('knit', '1.6', False),
34
 
#        ('pack-0.92', '1.6', False),
35
 
        ('1.6', '1.6.1-rich-root', True),
36
 
        ]
37
 
    scenarios = []
38
 
    for (old_name, new_name, model_change) in scenario_pairs:
39
 
        name = old_name + ', ' + new_name
40
 
        scenarios.append((name,
41
 
            dict(scenario_old_format=old_name,
42
 
                scenario_new_format=new_name,
43
 
                scenario_model_change=model_change)))
44
 
    return scenarios
45
 
 
46
 
 
47
 
load_tests = load_tests_apply_scenarios
48
26
 
49
27
 
50
28
class TestStackUpgrade(tests.TestCaseWithTransport):
51
29
    # TODO: This should possibly be repeated for all stacking repositories,
52
30
    # pairwise by rich/non-rich format; should possibly also try other kinds
53
31
    # of upgrades like knit->pack. -- mbp 20080804
54
 
    
55
 
    scenarios = upgrade_scenarios()
56
32
 
57
33
    def test_stack_upgrade(self):
58
34
        """Correct checks when stacked-on repository is upgraded.
59
 
 
60
 
        We initially stack on a repo with the same rich root support,
61
 
        we then upgrade it and should fail, we then upgrade the overlaid
 
35
        
 
36
        We initially stack on a repo with the same rich root support, 
 
37
        we then upgrade it and should fail, we then upgrade the overlaid 
62
38
        repository.
63
39
        """
64
40
        base = self.make_branch_and_tree('base',
71
47
        self.assertTrue(stacked.open_branch().get_stacked_on_url())
72
48
        # now we'll upgrade the underlying branch, then upgrade the stacked
73
49
        # branch, and this should still work.
74
 
        new_format = controldir.format_registry.make_bzrdir(
 
50
        new_format = bzrdir.format_registry.make_bzrdir(
75
51
            self.scenario_new_format)
76
52
        upgrade('base', new_format)
77
53
        # in some cases you'll get an error if the underlying model has
80
56
            self.assertRaises(errors.IncompatibleRepositories,
81
57
                stacked.open_branch)
82
58
        else:
83
 
            check.check_dwim('stacked', False, True, True)
84
 
        stacked = controldir.ControlDir.open('stacked')
 
59
            stacked.open_branch().check()
 
60
        stacked = bzrdir.BzrDir.open('stacked')
85
61
        # but we can upgrade the stacked repository
86
62
        upgrade('stacked', new_format)
87
 
        # and now it opens ok
88
 
        stacked = controldir.ControlDir.open('stacked')
89
 
        # And passes check.
90
 
        check.check_dwim('stacked', False, True, True)
 
63
        # and now it's ok
 
64
        stacked = bzrdir.BzrDir.open('stacked')
 
65
        stacked.open_branch().check()
 
66
 
 
67
 
 
68
def load_tests(basic_tests, module, test_loader):
 
69
    """Generate dynamic scenario tests.
 
70
 
 
71
    Called by the bzrlib test framework.
 
72
    """
 
73
    scenario_pairs = [ # old format, new format, model_change
 
74
#        ('knit', 'rich-root', True),
 
75
        ('knit', '1.6', False),
 
76
#        ('pack-0.92', '1.6', False),
 
77
        ('1.6', '1.6.1-rich-root', True),
 
78
        ]
 
79
    scenarios = []
 
80
    for (old_name, new_name, model_change) in scenario_pairs:
 
81
        name = old_name + ', ' + new_name
 
82
        scenarios.append((name,
 
83
            dict(scenario_old_format=old_name,
 
84
                scenario_new_format=new_name,
 
85
                scenario_model_change=model_change)))
 
86
    adapter = tests.TestScenarioApplier()
 
87
    adapter.scenarios = scenarios
 
88
    suite = tests.TestSuite()
 
89
    tests.adapt_tests(basic_tests, adapter, suite)
 
90
    return suite