1
# Copyright (C) 2006 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
"""Tests for remote bzrdir/branch/repo/etc
19
These are proxy objects which act on remote objects by sending messages
20
through a smart client. The proxies are to be created when attempting to open
21
the object given a transport that supports smartserver rpc operations.
24
from bzrlib import bzrdir, remote, tests
25
from bzrlib.transport import remote as remote_transport
26
from bzrlib import smart
27
from bzrlib.smart import server
28
from bzrlib.bzrdir import BzrDir, BzrDirFormat
29
from bzrlib.remote import RemoteBzrDir, RemoteBzrDirFormat
30
from bzrlib.branch import Branch
33
class BasicRemoteObjectTests(tests.TestCaseWithTransport):
36
super(BasicRemoteObjectTests, self).setUp()
37
self.transport_server = server.SmartTCPServer_for_testing
38
self.transport = self.get_transport()
39
self.client = self.transport.get_smart_client()
40
# make a branch that can be opened over the smart transport
41
self.local_wt = BzrDir.create_standalone_workingtree('.')
43
def test_create_remote_bzrdir(self):
44
b = remote.RemoteBzrDir(self.transport)
45
self.assertIsInstance(b, BzrDir)
47
def test_open_remote_branch(self):
48
# open a standalone branch in the working directory
49
b = remote.RemoteBzrDir(self.transport)
50
branch = b.open_branch()
52
def test_remote_repository(self):
53
b = BzrDir.open_from_transport(self.transport)
54
repo = b.open_repository()
55
revid = u'\xc823123123'
56
self.assertFalse(repo.has_revision(revid))
57
self.local_wt.commit(message='test commit', rev_id=revid)
58
self.assertTrue(repo.has_revision(revid))
60
def test_remote_branch_revision_history(self):
61
b = BzrDir.open_from_transport(self.transport).open_branch()
62
self.assertEqual([], b.revision_history())
63
r1 = self.local_wt.commit('1st commit')
64
r2 = self.local_wt.commit('1st commit', rev_id=u'\xc8')
65
self.assertEqual([r1, r2], b.revision_history())
67
def test_find_correct_format(self):
68
"""Should open a RemoteBzrDir over a RemoteTransport"""
69
fmt = BzrDirFormat.find_format(self.transport)
70
self.assertTrue(RemoteBzrDirFormat in BzrDirFormat._control_formats)
71
self.assertIsInstance(fmt, remote.RemoteBzrDirFormat)
73
def test_open_detected_smart_format(self):
74
fmt = BzrDirFormat.find_format(self.transport)
75
d = fmt.open(self.transport)
76
self.assertIsInstance(d, BzrDir)