~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_http.py

  • Committer: Vincent Ladeuil
  • Date: 2010-06-11 10:59:23 UTC
  • mto: (5247.1.7 first-try)
  • mto: This revision was merged to the branch mainline in revision 5326.
  • Revision ID: v.ladeuil+lp@free.fr-20100611105923-c3uz1j77sh4bnkhh
The default http protocol version wasn't properly defined and as such not respected by some parametrized tests.

* bzrlib/tests/test_http.py:
(load_tests): Some tests need to be parametrized by the protocol
version only.
(TestAuthOnRedirected): These test are for urllib only but should
be parametrized by the http protocol version.

* bzrlib/tests/test_bzrdir.py:
(TestHTTPRedirections): Mention that we rely on the default http
protocol version.

* bzrlib/tests/http_utils.py:
(TestCaseWithWebserver): Set a default protocol version that can
be overriden by daughter classes.
(TestCaseWithWebserver.create_transport_readonly_server)
(TestCaseWithTwoWebservers.create_transport_secondary_server)
(TestCaseWithRedirectedWebserver.create_transport_secondary_server):
Ouch, the http protocol version is lost if we don't propagate it.

Show diffs side-by-side

added added

removed removed

Lines of Context:
89
89
                            _qualified_prefix='http+pycurl',)))
90
90
    tests.multiply_tests(t_tests, transport_scenarios, result)
91
91
 
 
92
    protocol_scenarios = [
 
93
            ('HTTP/1.0',  dict(_protocol_version='HTTP/1.0')),
 
94
            ('HTTP/1.1',  dict(_protocol_version='HTTP/1.1')),
 
95
            ]
 
96
 
 
97
    # some tests are parametrized by the protocol version only
 
98
    p_tests, remaining_tests = tests.split_suite_by_condition(
 
99
        remaining_tests, tests.condition_isinstance((
 
100
                TestAuthOnRedirected,
 
101
                )))
 
102
    tests.multiply_tests(p_tests, protocol_scenarios, result)
 
103
 
92
104
    # each implementation tested with each HTTP version
93
105
    tp_tests, remaining_tests = tests.split_suite_by_condition(
94
106
        remaining_tests, tests.condition_isinstance((
103
115
                TestRanges,
104
116
                TestSpecificRequestHandler,
105
117
                )))
106
 
    protocol_scenarios = [
107
 
            ('HTTP/1.0',  dict(_protocol_version='HTTP/1.0')),
108
 
            ('HTTP/1.1',  dict(_protocol_version='HTTP/1.1')),
109
 
            ]
110
118
    tp_scenarios = tests.multiply_scenarios(transport_scenarios,
111
119
                                            protocol_scenarios)
112
120
    tests.multiply_tests(tp_tests, tp_scenarios, result)
2156
2164
    _transport = _urllib.HttpTransport_urllib
2157
2165
 
2158
2166
    def create_transport_readonly_server(self):
2159
 
        return self._auth_server()
 
2167
        return self._auth_server(protocol_version=self._protocol_version)
2160
2168
 
2161
2169
    def create_transport_secondary_server(self):
2162
2170
        """Create the secondary server redirecting to the primary server"""
2163
2171
        new = self.get_readonly_server()
2164
2172
 
2165
 
        redirecting = http_utils.HTTPServerRedirecting()
 
2173
        redirecting = http_utils.HTTPServerRedirecting(
 
2174
            protocol_version=self._protocol_version)
2166
2175
        redirecting.redirect_to(new.host, new.port)
2167
2176
        return redirecting
2168
2177