~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_smart_transport.py

  • Committer: Andrew Bennetts
  • Date: 2009-07-08 07:03:38 UTC
  • mto: This revision was merged to the branch mainline in revision 4523.
  • Revision ID: andrew.bennetts@canonical.com-20090708070338-70crapsdixamosuf
Fix bug in HPSS v3 decoder when receiving multiple lots of excess bytes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2297
2297
        self.assertEqual(0, smart_protocol.next_read_size())
2298
2298
        self.assertEqual('', smart_protocol.unused_data)
2299
2299
 
 
2300
    def test_repeated_excess(self):
 
2301
        """Repeated calls to accept_bytes after the message end has been parsed
 
2302
        accumlates the bytes in the unused_data attribute.
 
2303
        """
 
2304
        output = StringIO()
 
2305
        headers = '\0\0\0\x02de'  # length-prefixed, bencoded empty dict
 
2306
        end = 'e'
 
2307
        request_bytes = headers + end
 
2308
        smart_protocol = self.server_protocol_class(LoggingMessageHandler())
 
2309
        smart_protocol.accept_bytes(request_bytes)
 
2310
        self.assertEqual('', smart_protocol.unused_data)
 
2311
        smart_protocol.accept_bytes('aaa')
 
2312
        self.assertEqual('aaa', smart_protocol.unused_data)
 
2313
        smart_protocol.accept_bytes('bbb')
 
2314
        self.assertEqual('aaabbb', smart_protocol.unused_data)
 
2315
        self.assertEqual(0, smart_protocol.next_read_size())
 
2316
 
2300
2317
    def make_protocol_expecting_message_part(self):
2301
2318
        headers = '\0\0\0\x02de'  # length-prefixed, bencoded empty dict
2302
2319
        message_handler = LoggingMessageHandler()