~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_remote.py

  • Committer: Andrew Bennetts
  • Date: 2007-02-08 06:51:30 UTC
  • mto: (2018.5.73 hpss)
  • mto: This revision was merged to the branch mainline in revision 2435.
  • Revision ID: andrew.bennetts@canonical.com-20070208065130-gpzocn512ppmcm72
Add a Branch.set_last_revision smart method, and make RemoteBranch.set_revision_history use it.

Show diffs side-by-side

added added

removed removed

Lines of Context:
155
155
        self.assertEqual((2, u'\xc8'), result)
156
156
 
157
157
 
 
158
class TestBranchSetLastRevision(tests.TestCase):
 
159
 
 
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')
 
167
 
 
168
        bzrdir = RemoteBzrDir(transport, _client=False)
 
169
        branch = RemoteBranch(bzrdir, None, _client=client)
 
170
 
 
171
        result = branch.set_revision_history([])
 
172
        self.assertEqual(
 
173
            [('call', 'Branch.set_last_revision', ('///branch/', ''))],
 
174
            client._calls)
 
175
        self.assertEqual(None, result)
 
176
 
 
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')
 
184
 
 
185
        bzrdir = RemoteBzrDir(transport, _client=False)
 
186
        branch = RemoteBranch(bzrdir, None, _client=client)
 
187
 
 
188
        result = branch.set_revision_history(['rev-id1', 'rev-id2'])
 
189
        self.assertEqual(
 
190
            [('call', 'Branch.set_last_revision', ('///branch/', 'rev-id2'))],
 
191
            client._calls)
 
192
        self.assertEqual(None, result)
 
193
 
 
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')
 
200
 
 
201
        bzrdir = RemoteBzrDir(transport, _client=False)
 
202
        branch = RemoteBranch(bzrdir, None, _client=client)
 
203
 
 
204
        self.assertRaises(
 
205
            NoSuchRevision, branch.set_revision_history, ['rev-id'])
 
206
 
 
207
 
158
208
class TestBranchControlGetBranchConf(tests.TestCase):
159
209
    """Test branch.control_files api munging...
160
210
 
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'.