155
155
self.assertEqual((2, u'\xc8'), result)
158
class TestBranchSetLastRevision(tests.TestCase):
160
def test_set_empty(self):
161
# set_revision_history([]) is translated to calling
162
# Branch.set_last_revision(path, '') on the wire.
163
client = FakeClient([(('ok',), )])
164
transport = MemoryTransport()
165
transport.mkdir('branch')
166
transport = transport.clone('branch')
168
bzrdir = RemoteBzrDir(transport, _client=False)
169
branch = RemoteBranch(bzrdir, None, _client=client)
171
result = branch.set_revision_history([])
173
[('call', 'Branch.set_last_revision', ('///branch/', ''))],
175
self.assertEqual(None, result)
177
def test_set_nonempty(self):
178
# set_revision_history([rev-id1, ..., rev-idN]) is translated to calling
179
# Branch.set_last_revision(path, rev-idN) on the wire.
180
client = FakeClient([(('ok',), )])
181
transport = MemoryTransport()
182
transport.mkdir('branch')
183
transport = transport.clone('branch')
185
bzrdir = RemoteBzrDir(transport, _client=False)
186
branch = RemoteBranch(bzrdir, None, _client=client)
188
result = branch.set_revision_history(['rev-id1', 'rev-id2'])
190
[('call', 'Branch.set_last_revision', ('///branch/', 'rev-id2'))],
192
self.assertEqual(None, result)
194
def test_no_such_revision(self):
195
# A response of 'NoSuchRevision' is translated into an exception.
196
client = FakeClient([(('NoSuchRevision', 'rev-id'), )])
197
transport = MemoryTransport()
198
transport.mkdir('branch')
199
transport = transport.clone('branch')
201
bzrdir = RemoteBzrDir(transport, _client=False)
202
branch = RemoteBranch(bzrdir, None, _client=client)
205
NoSuchRevision, branch.set_revision_history, ['rev-id'])
158
208
class TestBranchControlGetBranchConf(tests.TestCase):
159
209
"""Test branch.control_files api munging...
161
we special case RemoteBranch.control_files.get('branch.conf') to
211
we special case RemoteBranch.control_files.get('branch.conf') to
162
212
call a specific API so that RemoteBranch's can intercept configuration
163
213
file reading, allowing them to signal to the client about things like
164
214
'email is configured for commits'.
194
244
return repo, client
197
class TestRepositoryGatherStats(tests.TestCase):
199
def setup_fake_client_and_repository(self, responses, transport_path):
200
"""Create the fake client and repository for testing with."""
201
client = FakeClient(responses)
202
transport = MemoryTransport()
203
transport.mkdir(transport_path)
204
transport = transport.clone(transport_path)
205
# we do not want bzrdir to make any remote calls
206
bzrdir = RemoteBzrDir(transport, _client=False)
207
repo = RemoteRepository(bzrdir, None, _client=client)
247
class TestRepositoryGatherStats(TestRemoteRepository):
210
249
def test_revid_none(self):
211
250
# ('ok',), body with revisions and size