/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/HTTPTestUtil.py

  • Committer: Vincent Ladeuil
  • Date: 2007-11-29 23:22:01 UTC
  • mto: (3059.2.1 173010)
  • mto: This revision was merged to the branch mainline in revision 3060.
  • Revision ID: v.ladeuil+lp@free.fr-20071129232201-thjmmlgo5ucbrwfn
Add tests and fix trivial bugs and other typos.

* bzrlib/transport/http/response.py:
(handle_response): Delete obsolete TODO.

* bzrlib/transport/http/__init__.py:
(HttpTransportBase._readv): Fix some trivial bugs revealed by the
test suite.
(HttpTransportBase._coalesce_readv): Fix list splice access, first
seen by jam, but found by the test suite too.

* bzrlib/tests/test_http.py:
Fix some imports.
(TestRangeRequestServer.test_readv_multiple_get_requests):
Exercise the rewritten readv.

* bzrlib/tests/HttpServer.py:
(TestingHTTPRequestHandler.do_GET): Count the requests (more tests
use that info).

* bzrlib/tests/HTTPTestUtil.py:
(LimitedRangeRequestHandler.do_GET): The statistics are collected
in the base request handler now.
(NoRangeRequestHandler.do_GET): But since we bypass the base
handler, re-enable the statistics collection here.

Show diffs side-by-side

added added

removed removed

Lines of Context:
164
164
        return TestingHTTPRequestHandler.get_multiple_ranges(self, file,
165
165
                                                             file_size, ranges)
166
166
 
167
 
    def do_GET(self):
168
 
        tcs = self.server.test_case_server
169
 
        tcs.GET_request_nb += 1
170
 
        return TestingHTTPRequestHandler.do_GET(self)
171
 
 
172
167
 
173
168
class LimitedRangeHTTPServer(HttpServer):
174
169
    """An HttpServer erroring out on requests with too much range specifiers"""
177
172
                 range_limit=None):
178
173
        HttpServer.__init__(self, request_handler)
179
174
        self.range_limit = range_limit
180
 
        self.GET_request_nb = 0
181
175
 
182
176
 
183
177
class SingleRangeRequestHandler(TestingHTTPRequestHandler):
208
202
class NoRangeRequestHandler(TestingHTTPRequestHandler):
209
203
    """Ignore range requests without notice"""
210
204
 
211
 
    # Just bypass the range handling done by TestingHTTPRequestHandler
212
 
    do_GET = SimpleHTTPRequestHandler.do_GET
 
205
    def do_GET(self):
 
206
        # Update the statistics
 
207
        self.server.test_case_server.GET_request_nb += 1
 
208
        # Just bypass the range handling done by TestingHTTPRequestHandler
 
209
        return SimpleHTTPRequestHandler.do_GET(self)
213
210
 
214
211
 
215
212
class TestCaseWithWebserver(TestCaseWithTransport):