~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_http_response.py

  • Committer: Patch Queue Manager
  • Date: 2014-02-12 18:22:22 UTC
  • mfrom: (6589.2.1 trunk)
  • Revision ID: pqm@pqm.ubuntu.com-20140212182222-beouo25gaf1cny76
(vila) The XDG Base Directory Specification uses the XDG_CACHE_HOME,
 not XDG_CACHE_DIR. (Andrew Starr-Bochicchio)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006, 2007 Canonical Ltd
 
1
# Copyright (C) 2006-2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
75
75
        pass
76
76
 
77
77
 
 
78
class TestResponseFileIter(tests.TestCase):
 
79
 
 
80
    def test_iter_empty(self):
 
81
        f = response.ResponseFile('empty', StringIO())
 
82
        self.assertEqual([], list(f))
 
83
 
 
84
    def test_iter_many(self):
 
85
        f = response.ResponseFile('many', StringIO('0\n1\nboo!\n'))
 
86
        self.assertEqual(['0\n', '1\n', 'boo!\n'], list(f))
 
87
 
 
88
 
78
89
class TestHTTPConnection(tests.TestCase):
79
90
 
80
91
    def test_cleanup_pipe(self):
96
107
        # Override the thresold to force the warning emission
97
108
        conn._range_warning_thresold = 6 # There are 7 bytes pending
98
109
        conn.cleanup_pipe()
99
 
        self.assertContainsRe(self._get_log(keep_log_file=True),
100
 
                              'Got a 200 response when asking')
 
110
        self.assertContainsRe(self.get_log(), 'Got a 200 response when asking')
101
111
 
102
112
 
103
113
class TestRangeFileMixin(object):
138
148
 
139
149
    def test_read_zero(self):
140
150
        f = self._file
141
 
        start = self.first_range_start
142
151
        self.assertEquals('', f.read(0))
143
152
        f.seek(10, 1)
144
153
        self.assertEquals('', f.read(0))
372
381
 
373
382
    def test_seek_across_ranges(self):
374
383
        f = self._file
375
 
        start = self.first_range_start
376
384
        f.seek(126) # skip the two first ranges
377
385
        self.assertEquals('AB', f.read(2))
378
386
 
379
387
    def test_checked_read_dont_overflow_buffers(self):
380
388
        f = self._file
381
 
        start = self.first_range_start
382
389
        # We force a very low value to exercise all code paths in _checked_read
383
390
        f._discarded_buf_size = 8
384
391
        f.seek(126) # skip the two first ranges
801
808
    """
802
809
 
803
810
    def setUp(self):
804
 
        tests.TestCase.setUp(self)
 
811
        super(TestRangeFileSizeReadLimited, self).setUp()
805
812
        # create a test datablock larger than _max_read_size.
806
813
        chunk_size = response.RangeFile._max_read_size
807
814
        test_pattern = '0123456789ABCDEF'