~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: 2008-06-05 04:05:05 UTC
  • mfrom: (3473.1.1 ianc-integration)
  • Revision ID: pqm@pqm.ubuntu.com-20080605040505-i9kqxg2fps2qjdi0
Add the 'alias' command (Tim Penhey)

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
 
35
35
import bzrlib
36
36
from bzrlib import (
37
 
    bzrdir,
38
37
    config,
39
38
    errors,
40
39
    osutils,
41
 
    remote as _mod_remote,
42
40
    tests,
43
41
    transport,
44
42
    ui,
449
447
            '"GET /foo/bar HTTP/1.1" 200 - "-" "bzr/%s'
450
448
            % bzrlib.__version__) > -1)
451
449
 
 
450
    def test_get_smart_medium(self):
 
451
        # For HTTP, get_smart_medium should return the transport object.
 
452
        server = self.get_readonly_server()
 
453
        http_transport = self._transport(server.get_url())
 
454
        medium = http_transport.get_smart_medium()
 
455
        self.assertIs(medium, http_transport)
 
456
 
452
457
    def test_has_on_bogus_host(self):
453
458
        # Get a free address and don't 'accept' on it, so that we
454
459
        # can be sure there is no http handler there, but set a
1138
1143
        url = self.server.get_url()
1139
1144
        t = self._transport(url)
1140
1145
        try:
1141
 
            self.assertEqual('proxied contents of foo\n', t.get('foo').read())
 
1146
            self.assertEqual(t.get('foo').read(), 'proxied contents of foo\n')
1142
1147
        finally:
1143
1148
            self._restore_env()
1144
1149
 
1147
1152
        url = self.server.get_url()
1148
1153
        t = self._transport(url)
1149
1154
        try:
1150
 
            self.assertEqual('contents of foo\n', t.get('foo').read())
 
1155
            self.assertEqual(t.get('foo').read(), 'contents of foo\n')
1151
1156
        finally:
1152
1157
            self._restore_env()
1153
1158
 
1662
1667
        return http_utils.HTTPServerWithSmarts(
1663
1668
            protocol_version=self._protocol_version)
1664
1669
 
1665
 
    def test_open_bzrdir(self):
1666
 
        branch = self.make_branch('relpath')
1667
 
        http_server = self.get_readonly_server()
1668
 
        url = http_server.get_url() + 'relpath'
1669
 
        bd = bzrdir.BzrDir.open(url)
1670
 
        self.assertIsInstance(bd, _mod_remote.RemoteBzrDir)
1671
 
 
1672
1670
    def test_bulk_data(self):
1673
1671
        # We should be able to send and receive bulk data in a single message.
1674
1672
        # The 'readv' command in the smart protocol both sends and receives
1740
1738
        # No need to build a valid smart request here, the server will not even
1741
1739
        # try to interpret it.
1742
1740
        self.assertRaises(errors.SmartProtocolError,
1743
 
                          t.get_smart_medium().send_http_smart_request,
1744
 
                          'whatever')
 
1741
                          t.send_http_smart_request, 'whatever')
1745
1742