~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_smart_transport.py

  • Committer: Robert Collins
  • Date: 2007-04-24 12:20:09 UTC
  • mto: (2432.3.5 hpss-vfs-fallback)
  • mto: This revision was merged to the branch mainline in revision 2463.
  • Revision ID: robertc@lifelesswks.robertcollins.net-20070424122009-8bb4dede6a298d93
Make using SuccessfulSmartServerResponse and FailedSmartServerResponse mandatory rather than optional in smart server logic.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1267
1267
            def do_body(cmd, body_bytes):
1268
1268
                self.end_received = True
1269
1269
                self.assertEqual('abcdefg', body_bytes)
1270
 
                return request.SmartServerResponse(('ok', ))
 
1270
                return request.SuccessfulSmartServerResponse(('ok', ))
1271
1271
        smart_protocol.request._command = FakeCommand()
1272
1272
        # Call accept_bytes to make sure that internal state like _body_decoder
1273
1273
        # is initialised.  This test should probably be given a clearer
1409
1409
            request.SuccessfulSmartServerResponse(('x',)))
1410
1410
        self.assertEqual(0, smart_protocol.next_read_size())
1411
1411
 
 
1412
    def test__send_response_errors_with_base_response(self):
 
1413
        """Ensure that only the Successful/Failed subclasses are used."""
 
1414
        smart_protocol = protocol.SmartServerRequestProtocolOne(
 
1415
            None, lambda x: None)
 
1416
        self.assertRaises(AttributeError, smart_protocol._send_response,
 
1417
            request.SmartServerResponse(('x',)))
 
1418
 
1412
1419
    def test_query_version(self):
1413
1420
        """query_version on a SmartClientProtocolOne should return a number.
1414
1421
        
1627
1634
            request.SuccessfulSmartServerResponse(('x',)))
1628
1635
        self.assertEqual(0, smart_protocol.next_read_size())
1629
1636
 
 
1637
    def test__send_response_errors_with_base_response(self):
 
1638
        """Ensure that only the Successful/Failed subclasses are used."""
 
1639
        smart_protocol = protocol.SmartServerRequestProtocolOne(
 
1640
            None, lambda x: None)
 
1641
        self.assertRaises(AttributeError, smart_protocol._send_response,
 
1642
            request.SmartServerResponse(('x',)))
 
1643
 
1630
1644
    def test_query_version(self):
1631
1645
        """query_version on a SmartClientProtocolTwo should return a number.
1632
1646