64
64
from bzrlib.transport.http._pycurl import PyCurlTransport
67
def load_tests(standard_tests, module, loader):
68
"""Multiply tests for http clients and protocol versions."""
69
result = loader.suiteClass()
71
# one for each transport implementation
72
t_tests, remaining_tests = tests.split_suite_by_condition(
73
standard_tests, tests.condition_isinstance((
74
TestHttpTransportRegistration,
75
TestHttpTransportUrls,
67
load_tests = load_tests_apply_scenarios
70
def vary_by_http_client_implementation():
71
"""Test the two libraries we can use, pycurl and urllib."""
78
72
transport_scenarios = [
79
73
('urllib', dict(_transport=_urllib.HttpTransport_urllib,
80
74
_server=http_server.HttpServer_urllib,
85
79
('pycurl', dict(_transport=PyCurlTransport,
86
80
_server=http_server.HttpServer_PyCurl,
87
81
_url_protocol='http+pycurl',)))
88
tests.multiply_tests(t_tests, transport_scenarios, result)
90
protocol_scenarios = [
91
('HTTP/1.0', dict(_protocol_version='HTTP/1.0')),
92
('HTTP/1.1', dict(_protocol_version='HTTP/1.1')),
95
# some tests are parametrized by the protocol version only
96
p_tests, remaining_tests = tests.split_suite_by_condition(
97
remaining_tests, tests.condition_isinstance((
100
tests.multiply_tests(p_tests, protocol_scenarios, result)
102
# each implementation tested with each HTTP version
103
tp_tests, remaining_tests = tests.split_suite_by_condition(
104
remaining_tests, tests.condition_isinstance((
105
SmartHTTPTunnellingTest,
106
TestDoCatchRedirections,
108
TestHTTPRedirections,
109
TestHTTPSilentRedirections,
110
TestLimitedRangeRequestServer,
114
TestSpecificRequestHandler,
116
tp_scenarios = tests.multiply_scenarios(transport_scenarios,
118
tests.multiply_tests(tp_tests, tp_scenarios, result)
120
# proxy auth: each auth scheme on all http versions on all implementations.
121
tppa_tests, remaining_tests = tests.split_suite_by_condition(
122
remaining_tests, tests.condition_isinstance((
125
proxy_auth_scheme_scenarios = [
82
return transport_scenarios
85
def vary_by_http_protocol_version():
86
"""Test on http/1.0 and 1.1"""
88
('HTTP/1.0', dict(_protocol_version='HTTP/1.0')),
89
('HTTP/1.1', dict(_protocol_version='HTTP/1.1')),
93
def vary_by_http_proxy_auth_scheme():
126
95
('basic', dict(_auth_server=http_utils.ProxyBasicAuthServer)),
127
96
('digest', dict(_auth_server=http_utils.ProxyDigestAuthServer)),
129
dict(_auth_server=http_utils.ProxyBasicAndDigestAuthServer)),
98
dict(_auth_server=http_utils.ProxyBasicAndDigestAuthServer)),
131
tppa_scenarios = tests.multiply_scenarios(tp_scenarios,
132
proxy_auth_scheme_scenarios)
133
tests.multiply_tests(tppa_tests, tppa_scenarios, result)
135
# auth: each auth scheme on all http versions on all implementations.
136
tpa_tests, remaining_tests = tests.split_suite_by_condition(
137
remaining_tests, tests.condition_isinstance((
140
auth_scheme_scenarios = [
102
def vary_by_http_auth_scheme():
141
104
('basic', dict(_auth_server=http_utils.HTTPBasicAuthServer)),
142
105
('digest', dict(_auth_server=http_utils.HTTPDigestAuthServer)),
144
dict(_auth_server=http_utils.HTTPBasicAndDigestAuthServer)),
107
dict(_auth_server=http_utils.HTTPBasicAndDigestAuthServer)),
146
tpa_scenarios = tests.multiply_scenarios(tp_scenarios,
147
auth_scheme_scenarios)
148
tests.multiply_tests(tpa_tests, tpa_scenarios, result)
150
# activity: on all http[s] versions on all implementations
151
tpact_tests, remaining_tests = tests.split_suite_by_condition(
152
remaining_tests, tests.condition_isinstance((
111
def vary_by_http_activity():
155
112
activity_scenarios = [
156
113
('urllib,http', dict(_activity_server=ActivityHTTPServer,
157
_transport=_urllib.HttpTransport_urllib,)),
114
_transport=_urllib.HttpTransport_urllib,)),
159
116
if tests.HTTPSServerFeature.available():
160
117
activity_scenarios.append(
161
118
('urllib,https', dict(_activity_server=ActivityHTTPSServer,
162
_transport=_urllib.HttpTransport_urllib,)),)
119
_transport=_urllib.HttpTransport_urllib,)),)
163
120
if features.pycurl.available():
164
121
activity_scenarios.append(
165
122
('pycurl,http', dict(_activity_server=ActivityHTTPServer,
166
_transport=PyCurlTransport,)),)
123
_transport=PyCurlTransport,)),)
167
124
if tests.HTTPSServerFeature.available():
168
125
from bzrlib.tests import (