~ubuntu-branches/ubuntu/precise/dulwich/precise-updates

« back to all changes in this revision

Viewing changes to dulwich/tests/test_protocol.py

  • Committer: Package Import Robot
  • Author(s): Jelmer Vernooij
  • Date: 2011-10-31 13:07:39 UTC
  • mto: This revision was merged to the branch mainline in revision 26.
  • Revision ID: package-import@ubuntu.com-20111031130739-pbg8ln7s3y3jpxwu
Tags: upstream-0.8.1
ImportĀ upstreamĀ versionĀ 0.8.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
    HangupException,
26
26
    )
27
27
from dulwich.protocol import (
 
28
    PktLineParser,
28
29
    Protocol,
29
30
    ReceivableProtocol,
30
31
    extract_capabilities,
280
281
        self._writer.write('z')
281
282
        self._writer.flush()
282
283
        self.assertOutputEquals('0005z')
 
284
 
 
285
 
 
286
class PktLineParserTests(TestCase):
 
287
 
 
288
    def test_none(self):
 
289
        pktlines = []
 
290
        parser = PktLineParser(pktlines.append)
 
291
        parser.parse("0000")
 
292
        self.assertEquals(pktlines, [None])
 
293
        self.assertEquals("", parser.get_tail())
 
294
 
 
295
    def test_small_fragments(self):
 
296
        pktlines = []
 
297
        parser = PktLineParser(pktlines.append)
 
298
        parser.parse("00")
 
299
        parser.parse("05")
 
300
        parser.parse("z0000")
 
301
        self.assertEquals(pktlines, ["z", None])
 
302
        self.assertEquals("", parser.get_tail())
 
303
 
 
304
    def test_multiple_packets(self):
 
305
        pktlines = []
 
306
        parser = PktLineParser(pktlines.append)
 
307
        parser.parse("0005z0006aba")
 
308
        self.assertEquals(pktlines, ["z", "ab"])
 
309
        self.assertEquals("a", parser.get_tail())