~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_http.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-09-18 02:51:19 UTC
  • mfrom: (4691.2.5 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20090918025119-eqkrmtj09t2hqs2t
(robertc) Add test suite enforcement of BzrDir objects outside the
        test area. (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
204
204
    It records the bytes sent to it, and replies with a 200.
205
205
    """
206
206
 
207
 
    def __init__(self, expect_body_tail=None):
 
207
    def __init__(self, expect_body_tail=None, scheme=''):
208
208
        """Constructor.
209
209
 
210
210
        :type expect_body_tail: str
215
215
        self.host = None
216
216
        self.port = None
217
217
        self.received_bytes = ''
 
218
        self.scheme = scheme
 
219
 
 
220
    def get_url(self):
 
221
        return '%s://%s:%s/' % (self.scheme, self.host, self.port)
218
222
 
219
223
    def setUp(self):
220
224
        self._sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
541
545
class TestPost(tests.TestCase):
542
546
 
543
547
    def test_post_body_is_received(self):
544
 
        server = RecordingServer(expect_body_tail='end-of-body')
 
548
        server = RecordingServer(expect_body_tail='end-of-body',
 
549
            scheme=self._qualified_prefix)
545
550
        self.start_server(server)
546
 
        scheme = self._qualified_prefix
547
 
        url = '%s://%s:%s/' % (scheme, server.host, server.port)
 
551
        url = server.get_url()
548
552
        http_transport = self._transport(url)
549
553
        code, response = http_transport._post('abc def end-of-body')
550
554
        self.assertTrue(
776
780
        self.assertEqual(None, server.port)
777
781
 
778
782
    def test_send_receive_bytes(self):
779
 
        server = RecordingServer(expect_body_tail='c')
 
783
        server = RecordingServer(expect_body_tail='c', scheme='http')
780
784
        self.start_server(server)
781
785
        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
782
786
        sock.connect((server.host, server.port))