~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_controldir/test_controldir.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-08-24 21:59:21 UTC
  • mfrom: (5363.2.22 controldir-1)
  • Revision ID: pqm@pqm.ubuntu.com-20100824215921-p4nheij9k4x6i1jw
(jelmer) Split generic interface code out of bzrlib.bzrdir.BzrDir into
 bzrlib.controldir.ControlDir. (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
from bzrlib import (
27
27
    bzrdir,
28
28
    check,
 
29
    controldir,
29
30
    errors,
30
31
    gpg,
31
 
    lockdir,
32
32
    osutils,
33
 
    repository,
34
33
    revision as _mod_revision,
35
 
    transactions,
36
34
    transport,
37
35
    ui,
38
36
    urlutils,
39
37
    workingtree,
40
38
    )
41
 
from bzrlib.branch import Branch, needs_read_lock, needs_write_lock
42
 
from bzrlib.errors import (FileExists,
43
 
                           NoSuchRevision,
44
 
                           NoSuchFile,
45
 
                           UninitializableFormat,
 
39
from bzrlib.errors import (NoSuchRevision,
46
40
                           NotBranchError,
47
41
                           )
48
42
import bzrlib.revision
49
43
from bzrlib.tests import (
50
44
                          ChrootedTestCase,
51
 
                          TestCase,
52
 
                          TestCaseWithTransport,
53
45
                          TestNotApplicable,
54
46
                          TestSkipped,
55
47
                          )
56
 
from bzrlib.tests.per_bzrdir import TestCaseWithBzrDir
57
 
from bzrlib.trace import mutter
 
48
from bzrlib.tests.per_controldir import TestCaseWithControlDir
58
49
from bzrlib.transport.local import LocalTransport
59
50
from bzrlib.ui import (
60
51
    CannedInputUIFactory,
61
52
    )
62
 
from bzrlib.upgrade import upgrade
63
53
from bzrlib.remote import RemoteBzrDir, RemoteRepository
64
54
from bzrlib.repofmt import weaverepo
65
55
 
66
56
 
67
 
class TestBzrDir(TestCaseWithBzrDir):
 
57
class TestControlDir(TestCaseWithControlDir):
68
58
    # Many of these tests test for disk equality rather than checking
69
59
    # for semantic equivalence. This works well for some tests but
70
60
    # is not good at handling changes in representation or the addition
264
254
        bzrdir.open_repository()
265
255
 
266
256
    def test_open_workingtree_raises_no_working_tree(self):
267
 
        """BzrDir.open_workingtree() should raise NoWorkingTree (rather than
 
257
        """ControlDir.open_workingtree() should raise NoWorkingTree (rather than
268
258
        e.g. NotLocalUrl) if there is no working tree.
269
259
        """
270
260
        dir = self.make_bzrdir('source')
271
261
        vfs_dir = bzrdir.BzrDir.open(self.get_vfs_only_url('source'))
272
262
        if vfs_dir.has_workingtree():
273
 
            # This BzrDir format doesn't support BzrDirs without working trees,
274
 
            # so this test is irrelevant.
 
263
            # This ControlDir format doesn't support ControlDirs without
 
264
            # working trees, so this test is irrelevant.
275
265
            return
276
266
        self.assertRaises(errors.NoWorkingTree, dir.open_workingtree)
277
267
 
1208
1198
        t = transport.get_transport(self.get_url())
1209
1199
        readonly_t = transport.get_transport(self.get_readonly_url())
1210
1200
        made_control = self.bzrdir_format.initialize(t.base)
1211
 
        self.failUnless(isinstance(made_control, bzrdir.BzrDir))
 
1201
        self.failUnless(isinstance(made_control, controldir.ControlDir))
1212
1202
        self.assertEqual(self.bzrdir_format,
1213
 
                         bzrdir.BzrDirFormat.find_format(readonly_t))
 
1203
                         controldir.ControlDirFormat.find_format(readonly_t))
1214
1204
        direct_opened_dir = self.bzrdir_format.open(readonly_t)
1215
1205
        opened_dir = bzrdir.BzrDir.open(t.base)
1216
1206
        self.assertEqual(made_control._format,
1217
1207
                         opened_dir._format)
1218
1208
        self.assertEqual(direct_opened_dir._format,
1219
1209
                         opened_dir._format)
1220
 
        self.failUnless(isinstance(opened_dir, bzrdir.BzrDir))
 
1210
        self.failUnless(isinstance(opened_dir, controldir.ControlDir))
1221
1211
 
1222
1212
    def test_format_initialize_on_transport_ex(self):
1223
1213
        t = self.get_transport('dir')
1767
1757
            self.assertTrue(isinstance(dir._format.get_converter(
1768
1758
                format=dir._format), bzrdir.Converter))
1769
1759
        dir.needs_format_conversion(
1770
 
            bzrdir.BzrDirFormat.get_default_format())
 
1760
            controldir.ControlDirFormat.get_default_format())
1771
1761
 
1772
1762
    def test_backup_copies_existing(self):
1773
1763
        tree = self.make_branch_and_tree('test')
1836
1826
            bd.retire_bzrdir, limit=0)
1837
1827
 
1838
1828
 
1839
 
class TestBreakLock(TestCaseWithBzrDir):
 
1829
class TestBreakLock(TestCaseWithControlDir):
1840
1830
 
1841
1831
    def test_break_lock_empty(self):
1842
1832
        # break lock on an empty bzrdir should work silently.
1944
1934
        self.assertRaises(errors.LockBroken, tree.unlock)
1945
1935
 
1946
1936
 
1947
 
class TestTransportConfig(TestCaseWithBzrDir):
 
1937
class TestTransportConfig(TestCaseWithControlDir):
1948
1938
 
1949
1939
    def test_get_config(self):
1950
1940
        my_dir = self.make_bzrdir('.')
1966
1956
        self.assertEqual('http://example.com', config2.get_default_stack_on())
1967
1957
 
1968
1958
 
1969
 
class ChrootedBzrDirTests(ChrootedTestCase):
 
1959
class ChrootedControlDirTests(ChrootedTestCase):
1970
1960
 
1971
1961
    def test_find_repository_no_repository(self):
1972
1962
        # loopback test to check the current format fails to find a
1994
1984
                          made_control.find_repository)
1995
1985
 
1996
1986
 
1997
 
class TestBzrDirControlComponent(TestCaseWithBzrDir):
1998
 
    """BzrDir implementations adequately implement ControlComponent."""
 
1987
class TestControlDirControlComponent(TestCaseWithControlDir):
 
1988
    """ControlDir implementations adequately implement ControlComponent."""
1999
1989
 
2000
1990
    def test_urls(self):
2001
1991
        bd = self.make_bzrdir('bd')