~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_smart_transport.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-09-14 01:48:19 UTC
  • mfrom: (4634.6.30 remove-args_received)
  • Revision ID: pqm@pqm.ubuntu.com-20090914014819-4yshlf6ooeeqznfs
(andrew) Remove SmartServerRequest.dispatch_command,
        fix SmartServerRequest.args_received.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1248
1248
 
1249
1249
    def test_hello(self):
1250
1250
        handler = self.build_handler(None)
1251
 
        handler.dispatch_command('hello', ())
 
1251
        handler.args_received(('hello',))
1252
1252
        self.assertEqual(('ok', '2'), handler.response.args)
1253
1253
        self.assertEqual(None, handler.response.body)
1254
1254
 
1268
1268
        """The response for a read-only error is ('ReadOnlyError')."""
1269
1269
        handler = self.build_handler(self.get_readonly_transport())
1270
1270
        # send a mkdir for foo, with no explicit mode - should fail.
1271
 
        handler.dispatch_command('mkdir', ('foo', ''))
 
1271
        handler.args_received(('mkdir', 'foo', ''))
1272
1272
        # and the failure should be an explicit ReadOnlyError
1273
1273
        self.assertEqual(("ReadOnlyError", ), handler.response.args)
1274
1274
        # XXX: TODO: test that other TransportNotPossible errors are
1279
1279
    def test_hello_has_finished_body_on_dispatch(self):
1280
1280
        """The 'hello' command should set finished_reading."""
1281
1281
        handler = self.build_handler(None)
1282
 
        handler.dispatch_command('hello', ())
 
1282
        handler.args_received(('hello',))
1283
1283
        self.assertTrue(handler.finished_reading)
1284
1284
        self.assertNotEqual(None, handler.response)
1285
1285
 
1286
1286
    def test_put_bytes_non_atomic(self):
1287
1287
        """'put_...' should set finished_reading after reading the bytes."""
1288
1288
        handler = self.build_handler(self.get_transport())
1289
 
        handler.dispatch_command('put_non_atomic', ('a-file', '', 'F', ''))
 
1289
        handler.args_received(('put_non_atomic', 'a-file', '', 'F', ''))
1290
1290
        self.assertFalse(handler.finished_reading)
1291
1291
        handler.accept_body('1234')
1292
1292
        self.assertFalse(handler.finished_reading)
1300
1300
        """'readv' should set finished_reading after reading offsets."""
1301
1301
        self.build_tree(['a-file'])
1302
1302
        handler = self.build_handler(self.get_readonly_transport())
1303
 
        handler.dispatch_command('readv', ('a-file', ))
 
1303
        handler.args_received(('readv', 'a-file'))
1304
1304
        self.assertFalse(handler.finished_reading)
1305
1305
        handler.accept_body('2,')
1306
1306
        self.assertFalse(handler.finished_reading)
1315
1315
        """'readv' when a short read occurs sets the response appropriately."""
1316
1316
        self.build_tree(['a-file'])
1317
1317
        handler = self.build_handler(self.get_readonly_transport())
1318
 
        handler.dispatch_command('readv', ('a-file', ))
 
1318
        handler.args_received(('readv', 'a-file'))
1319
1319
        # read beyond the end of the file.
1320
1320
        handler.accept_body('100,1')
1321
1321
        handler.end_of_body()
2542
2542
        self.calls.append(('end_received',))
2543
2543
        self.finished_reading = True
2544
2544
 
2545
 
    def dispatch_command(self, cmd, args):
2546
 
        self.calls.append(('dispatch_command', cmd, args))
 
2545
    def args_received(self, args):
 
2546
        self.calls.append(('args_received', args))
2547
2547
 
2548
2548
    def accept_body(self, bytes):
2549
2549
        self.calls.append(('accept_body', bytes))