~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_http.py

  • Committer: Matt Nordhoff
  • Date: 2009-06-23 05:12:07 UTC
  • mto: This revision was merged to the branch mainline in revision 4474.
  • Revision ID: mnordhoff@mattnordhoff.com-20090623051207-fksdtbzkwtnrw9dd
Update _add_text docstrings that still referred to add_text.

Show diffs side-by-side

added added

removed removed

Lines of Context:
304
304
 
305
305
        server = http_server.HttpServer(BogusRequestHandler)
306
306
        try:
307
 
            self.assertRaises(httplib.UnknownProtocol, server.setUp)
 
307
            self.assertRaises(httplib.UnknownProtocol,server.setUp)
308
308
        except:
309
309
            server.tearDown()
310
310
            self.fail('HTTP Server creation did not raise UnknownProtocol')
312
312
    def test_force_invalid_protocol(self):
313
313
        server = http_server.HttpServer(protocol_version='HTTP/0.1')
314
314
        try:
315
 
            self.assertRaises(httplib.UnknownProtocol, server.setUp)
 
315
            self.assertRaises(httplib.UnknownProtocol,server.setUp)
316
316
        except:
317
317
            server.tearDown()
318
318
            self.fail('HTTP Server creation did not raise UnknownProtocol')
320
320
    def test_server_start_and_stop(self):
321
321
        server = http_server.HttpServer()
322
322
        server.setUp()
323
 
        try:
324
 
            self.assertTrue(server._http_running)
325
 
        finally:
326
 
            server.tearDown()
 
323
        self.assertTrue(server._http_running)
 
324
        server.tearDown()
327
325
        self.assertFalse(server._http_running)
328
326
 
329
327
    def test_create_http_server_one_zero(self):
332
330
            protocol_version = 'HTTP/1.0'
333
331
 
334
332
        server = http_server.HttpServer(RequestHandlerOneZero)
335
 
        self.start_server(server)
 
333
        server.setUp()
 
334
        self.addCleanup(server.tearDown)
336
335
        self.assertIsInstance(server._httpd, http_server.TestingHTTPServer)
337
336
 
338
337
    def test_create_http_server_one_one(self):
341
340
            protocol_version = 'HTTP/1.1'
342
341
 
343
342
        server = http_server.HttpServer(RequestHandlerOneOne)
344
 
        self.start_server(server)
 
343
        server.setUp()
 
344
        self.addCleanup(server.tearDown)
345
345
        self.assertIsInstance(server._httpd,
346
346
                              http_server.TestingThreadingHTTPServer)
347
347
 
352
352
 
353
353
        server = http_server.HttpServer(RequestHandlerOneZero,
354
354
                                        protocol_version='HTTP/1.1')
355
 
        self.start_server(server)
 
355
        server.setUp()
 
356
        self.addCleanup(server.tearDown)
356
357
        self.assertIsInstance(server._httpd,
357
358
                              http_server.TestingThreadingHTTPServer)
358
359
 
363
364
 
364
365
        server = http_server.HttpServer(RequestHandlerOneOne,
365
366
                                        protocol_version='HTTP/1.0')
366
 
        self.start_server(server)
 
367
        server.setUp()
 
368
        self.addCleanup(server.tearDown)
367
369
        self.assertIsInstance(server._httpd,
368
370
                              http_server.TestingHTTPServer)
369
371
 
429
431
    def test_http_impl_urls(self):
430
432
        """There are servers which ask for particular clients to connect"""
431
433
        server = self._server()
432
 
        server.setUp()
433
434
        try:
 
435
            server.setUp()
434
436
            url = server.get_url()
435
437
            self.assertTrue(url.startswith('%s://' % self._qualified_prefix))
436
438
        finally:
542
544
 
543
545
    def test_post_body_is_received(self):
544
546
        server = RecordingServer(expect_body_tail='end-of-body')
545
 
        self.start_server(server)
 
547
        server.setUp()
 
548
        self.addCleanup(server.tearDown)
546
549
        scheme = self._qualified_prefix
547
550
        url = '%s://%s:%s/' % (scheme, server.host, server.port)
548
551
        http_transport = self._transport(url)
622
625
        # for details) make no distinction between a closed
623
626
        # socket and badly formatted status line, so we can't
624
627
        # just test for ConnectionError, we have to test
625
 
        # InvalidHttpResponse too. And pycurl may raise ConnectionReset
626
 
        # instead of ConnectionError too.
627
 
        self.assertRaises(( errors.ConnectionError, errors.ConnectionReset,
628
 
                            errors.InvalidHttpResponse),
 
628
        # InvalidHttpResponse too.
 
629
        self.assertRaises((errors.ConnectionError, errors.InvalidHttpResponse),
629
630
                          t.has, 'foo/bar')
630
631
 
631
632
    def test_http_get(self):
632
633
        server = self.get_readonly_server()
633
634
        t = self._transport(server.get_url())
634
 
        self.assertRaises((errors.ConnectionError, errors.ConnectionReset,
635
 
                           errors.InvalidHttpResponse),
 
635
        self.assertRaises((errors.ConnectionError, errors.InvalidHttpResponse),
636
636
                          t.get, 'foo/bar')
637
637
 
638
638
 
777
777
 
778
778
    def test_send_receive_bytes(self):
779
779
        server = RecordingServer(expect_body_tail='c')
780
 
        self.start_server(server)
 
780
        server.setUp()
 
781
        self.addCleanup(server.tearDown)
781
782
        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
782
783
        sock.connect((server.host, server.port))
783
784
        sock.sendall('abc')