/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/test_http.py

  • Committer: v.ladeuil+lp at free
  • Date: 2006-10-13 08:36:19 UTC
  • mto: (2145.1.1 keepalive)
  • mto: This revision was merged to the branch mainline in revision 2146.
  • Revision ID: v.ladeuil+lp@free.fr-20061013083619-502b7eed9abc3473
Cleaning.

* bzrlib/tests/test_http.py:
Oops, deleted dead code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
365
365
#                                   TestBadProtocolServer,
366
366
#                                   TestCaseWithWebserver):
367
367
#    """Tests BadProtocolServer for pycurl implementation"""
368
 
 
369
 
 
370
 
class TestRangesServer(object):
371
 
    """Tests range requests against a server.
372
 
 
373
 
    This MUST be used by daughter classes that also inherit from
374
 
    TestCaseWithWebserver.
375
 
 
376
 
    We can't inherit directly from TestCaseWithWebserver or the
377
 
    test framework will try to create an instance which cannot
378
 
    run, its implementation being incomplete.
379
 
    """
380
 
 
381
 
    def setUp(self):
382
 
        TestCaseWithWebserver.setUp(self)
383
 
        transport = self.get_transport()
384
 
        if transport.is_readonly():
385
 
            file('a', 'w').write('0123456789')
386
 
        else:
387
 
            transport.put_bytes('a', '0123456789')
388
 
 
389
 
    def test_single_range(self):
390
 
        server = self.get_readonly_server()
391
 
        t = self._transport(server.get_url())
392
 
        content = t.readv(_file_10, )
393
 
 
394
 
        self.assertRaises(errors.InvalidRange, out.read, 20)
395
 
 
396
 
        out.seek(100)
397
 
        self.assertEqual(_single_range_response[2], out.read(100))
398
 
 
399
 
    def test_single_range_no_content(self):
400
 
        out = self.get_response(_single_range_no_content_type)
401
 
        self.assertIsInstance(out, response.HttpRangeResponse)
402
 
 
403
 
        self.assertRaises(errors.InvalidRange, out.read, 20)
404
 
 
405
 
        out.seek(100)
406
 
        self.assertEqual(_single_range_no_content_type[2], out.read(100))
407
 
 
408
 
    def test_multi_range(self):
409
 
        out = self.get_response(_multipart_range_response)
410
 
        self.assertIsInstance(out, response.HttpMultipartRangeResponse)
411
 
 
412
 
        # Just make sure we can read the right contents
413
 
        out.seek(0)
414
 
        out.read(255)
415
 
 
416
 
        out.seek(1000)
417
 
        out.read(1050)
418
 
 
419
 
    def test_multi_squid_range(self):
420
 
        out = self.get_response(_multipart_squid_range_response)
421
 
        self.assertIsInstance(out, response.HttpMultipartRangeResponse)
422
 
 
423
 
        # Just make sure we can read the right contents
424
 
        out.seek(0)
425
 
        out.read(100)
426
 
 
427
 
        out.seek(300)
428
 
        out.read(200)
429
 
 
430
 
    def test_full_text_no_content_type(self):
431
 
        # We should not require Content-Type for a full response
432
 
        a_response = _full_text_response
433
 
        headers = http._extract_headers(a_response[1], 'http://foo')
434
 
        del headers['Content-Type']
435
 
        out = response.handle_response('http://foo', a_response[0], headers,
436
 
                                        StringIO(a_response[2]))
437
 
        self.assertEqual(_full_text_response[2], out.read())
438
 
 
439
 
    def test_missing_content_range(self):
440
 
        a_response = _single_range_response
441
 
        headers = http._extract_headers(a_response[1], 'http://nocontent')
442
 
        del headers['Content-Range']
443
 
        self.assertRaises(errors.InvalidHttpResponse,
444
 
            response.handle_response, 'http://nocontent', a_response[0],
445
 
                                      headers, StringIO(a_response[2]))