~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_smart.py

Add SmartServerBranchRequestLastRevisionInfo method.
(Wouter van Heyst, Robert Collins, Vincent Ladeuil)

Show diffs side-by-side

added added

removed removed

Lines of Context:
220
220
            request.execute, backing.local_abspath('checkout'))
221
221
 
222
222
 
 
223
class TestSmartServerBranchRequestLastRevisionInfo(tests.TestCaseWithTransport):
 
224
 
 
225
    def test_empty(self):
 
226
        """For an empty branch, the result is ('ok', '0', '')."""
 
227
        backing = self.get_transport()
 
228
        request = smart.branch.SmartServerBranchRequestLastRevisionInfo(backing)
 
229
        self.make_branch('.')
 
230
        self.assertEqual(SmartServerResponse(('ok', '0', '')),
 
231
            request.execute(backing.local_abspath('')))
 
232
 
 
233
    def test_not_empty(self):
 
234
        """For a non-empty branch, the result is ('ok', 'revno', 'revid')."""
 
235
        backing = self.get_transport()
 
236
        request = smart.branch.SmartServerBranchRequestLastRevisionInfo(backing)
 
237
        tree = self.make_branch_and_memory_tree('.')
 
238
        tree.lock_write()
 
239
        tree.add('')
 
240
        r1 = tree.commit('1st commit')
 
241
        r2 = tree.commit('2nd commit', rev_id=u'\xc8')
 
242
        tree.unlock()
 
243
        self.assertEqual(
 
244
            SmartServerResponse(('ok', '2', u'\xc8'.encode('utf8'))),
 
245
            request.execute(backing.local_abspath('')))
 
246
 
 
247
 
223
248
class TestHandlers(tests.TestCase):
224
249
    """Tests for the request.request_handlers object."""
225
250