1
# Copyright (C) 2005, 2006, 2007 Canonical Ltd
1
# Copyright (C) 2006-2010 Canonical Ltd
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
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
17
"""Black-box tests for repositories with shared branches"""
21
from bzrlib.bzrdir import BzrDir
21
from bzrlib.bzrdir import BzrDir, BzrDirMetaFormat1
22
22
import bzrlib.errors as errors
23
23
from bzrlib.tests import TestCaseInTempDir
27
27
def test_make_repository(self):
28
28
out, err = self.run_bzr("init-repository a")
29
29
self.assertEqual(out,
30
"""Shared repository with trees (format: pack-0.92)
30
"""Shared repository with trees (format: 2a)
32
32
shared repository: a
108
108
self.run_bzr("init-repo --no-trees notrees")
109
109
repo = BzrDir.open("notrees").open_repository()
110
110
self.assertEqual(False, repo.make_working_trees())
112
def test_init_repo_smart_acceptance(self):
113
# The amount of hpss calls made on init-repo to a smart server should
115
self.setup_smart_server_with_call_log()
116
self.run_bzr(['init-repo', self.get_url('repo')])
117
# This figure represent the amount of work to perform this use case. It
118
# is entirely ok to reduce this number if a test fails due to rpc_count
119
# being too low. If rpc_count increases, more network roundtrips have
120
# become necessary for this use case. Please do not adjust this number
121
# upwards without agreement from bzr's network support maintainers.
122
self.assertLength(15, self.hpss_calls)
124
def test_notification_on_branch_from_repository(self):
125
out, err = self.run_bzr("init-repository -q a")
126
self.assertEqual(out, "")
127
self.assertEqual(err, "")
128
dir = BzrDir.open('a')
129
dir.open_repository() # there is a repository there
130
e = self.assertRaises(errors.NotBranchError, dir.open_branch)
131
self.assertContainsRe(str(e), "location is a repository")
133
def test_notification_on_branch_from_nonrepository(self):
134
fmt = BzrDirMetaFormat1()
135
t = self.get_transport()
137
dir = fmt.initialize_on_transport(t.clone('a'))
138
self.assertRaises(errors.NoRepositoryPresent, dir.open_repository)
139
e = self.assertRaises(errors.NotBranchError, dir.open_branch)
140
self.assertNotContainsRe(str(e), "location is a repository")