1
# Copyright (C) 2005 by Canonical Ltd
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
"""Black-box tests for repositories with shared branches"""
21
from bzrlib.tests import TestCaseInTempDir
23
import bzrlib.errors as errors
25
class TestSharedRepo(TestCaseInTempDir):
27
def test_make_repository(self):
28
out, err = self.run_bzr("init-repository", "a")
29
self.assertEqual(out, "")
30
self.assertEqual(err, "")
31
dir = bzrlib.bzrdir.BzrDir.open('a')
32
self.assertIs(dir.open_repository().is_shared(), True)
33
self.assertRaises(errors.NotBranchError, dir.open_branch)
34
self.assertRaises(errors.NoWorkingTree, dir.open_workingtree)
37
self.run_bzr("init-repo", "a")
38
self.run_bzr("init", "--format=metadir", "a/b")
39
dir = bzrlib.bzrdir.BzrDir.open('a')
40
self.assertIs(dir.open_repository().is_shared(), True)
41
self.assertRaises(errors.NotBranchError, dir.open_branch)
42
self.assertRaises(errors.NoWorkingTree, dir.open_workingtree)
43
bdir = bzrlib.bzrdir.BzrDir.open('a/b')
45
self.assertRaises(errors.NoRepositoryPresent, bdir.open_repository)
46
self.assertRaises(errors.NoWorkingTree, bdir.open_workingtree)
48
def test_branch(self):
49
self.run_bzr("init-repo", "a")
50
self.run_bzr("init", "--format=metadir", "a/b")
51
self.run_bzr('branch', 'a/b', 'a/c')
52
cdir = bzrlib.bzrdir.BzrDir.open('a/c')
54
self.assertRaises(errors.NoRepositoryPresent, cdir.open_repository)
55
self.assertRaises(errors.NoWorkingTree, cdir.open_workingtree)