~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-03-06 06:48:25 UTC
  • mfrom: (4070.8.6 debug-config)
  • Revision ID: pqm@pqm.ubuntu.com-20090306064825-kbpwggw21dygeix6
(mbp) debug_flags configuration option

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
"""Tests for HTTP implementations.
18
18
 
71
71
def load_tests(standard_tests, module, loader):
72
72
    """Multiply tests for http clients and protocol versions."""
73
73
    result = loader.suiteClass()
 
74
    adapter = tests.TestScenarioApplier()
 
75
    remaining_tests = standard_tests
74
76
 
75
 
    # one for each transport implementation
 
77
    # one for each transport
76
78
    t_tests, remaining_tests = tests.split_suite_by_condition(
77
 
        standard_tests, tests.condition_isinstance((
 
79
        remaining_tests, tests.condition_isinstance((
78
80
                TestHttpTransportRegistration,
79
81
                TestHttpTransportUrls,
80
82
                Test_redirected_to,
89
91
            ('pycurl', dict(_transport=PyCurlTransport,
90
92
                            _server=http_server.HttpServer_PyCurl,
91
93
                            _qualified_prefix='http+pycurl',)))
92
 
    tests.multiply_tests(t_tests, transport_scenarios, result)
 
94
    adapter.scenarios = transport_scenarios
 
95
    tests.adapt_tests(t_tests, adapter, result)
93
96
 
94
 
    # each implementation tested with each HTTP version
 
97
    # multiplied by one for each protocol version
95
98
    tp_tests, remaining_tests = tests.split_suite_by_condition(
96
99
        remaining_tests, tests.condition_isinstance((
97
100
                SmartHTTPTunnellingTest,
109
112
            ('HTTP/1.0',  dict(_protocol_version='HTTP/1.0')),
110
113
            ('HTTP/1.1',  dict(_protocol_version='HTTP/1.1')),
111
114
            ]
112
 
    tp_scenarios = tests.multiply_scenarios(transport_scenarios,
 
115
    tp_scenarios = tests.multiply_scenarios(adapter.scenarios,
113
116
                                            protocol_scenarios)
114
 
    tests.multiply_tests(tp_tests, tp_scenarios, result)
 
117
    adapter.scenarios = tp_scenarios
 
118
    tests.adapt_tests(tp_tests, adapter, result)
115
119
 
116
 
    # auth: each auth scheme on all http versions on all implementations.
 
120
    # multiplied by one for each authentication scheme
117
121
    tpa_tests, remaining_tests = tests.split_suite_by_condition(
118
122
        remaining_tests, tests.condition_isinstance((
119
123
                TestAuth,
122
126
        ('basic', dict(_auth_scheme='basic')),
123
127
        ('digest', dict(_auth_scheme='digest')),
124
128
        ]
125
 
    tpa_scenarios = tests.multiply_scenarios(tp_scenarios,
126
 
        auth_scheme_scenarios)
127
 
    tests.multiply_tests(tpa_tests, tpa_scenarios, result)
 
129
    adapter.scenarios = tests.multiply_scenarios(adapter.scenarios,
 
130
                                                 auth_scheme_scenarios)
 
131
    tests.adapt_tests(tpa_tests, adapter, result)
128
132
 
129
 
    # activity: activity on all http versions on all implementations
130
133
    tpact_tests, remaining_tests = tests.split_suite_by_condition(
131
134
        remaining_tests, tests.condition_isinstance((
132
135
                TestActivity,
136
139
        ]
137
140
    if tests.HTTPSServerFeature.available():
138
141
        activity_scenarios.append(
139
 
            ('https', dict(_activity_server=ActivityHTTPSServer)))
140
 
    tpact_scenarios = tests.multiply_scenarios(tp_scenarios,
141
 
        activity_scenarios)
142
 
    tests.multiply_tests(tpact_tests, tpact_scenarios, result)
 
142
            ('https', dict(_activity_server=ActivityHTTPSServer,)))
 
143
    adapter.scenarios = tests.multiply_scenarios(tp_scenarios,
 
144
                                                 activity_scenarios)
 
145
    tests.adapt_tests(tpact_tests, adapter, result)
143
146
 
144
147
    # No parametrization for the remaining tests
145
148
    result.addTests(remaining_tests)
1307
1310
        # Since the tests using this class will replace
1308
1311
        # _urllib2_wrappers.Request, we can't just call the base class __init__
1309
1312
        # or we'll loop.
1310
 
        RedirectedRequest.init_orig(self, method, url, *args, **kwargs)
 
1313
        RedirectedRequest.init_orig(self, method, url, args, kwargs)
1311
1314
        self.follow_redirections = True
1312
1315
 
1313
1316
 
1905
1908
 
1906
1909
        # We override at class level because constructors may propagate the
1907
1910
        # bound method and render instance overriding ineffective (an
1908
 
        # alternative would be to define a specific ui factory instead...)
 
1911
        # alternative would be be to define a specific ui factory instead...)
1909
1912
        self.orig_report_activity = self._transport._report_activity
1910
1913
        self._transport._report_activity = report_activity
1911
1914