~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_http.py

  • Committer: Martin Pool
  • Date: 2010-10-08 09:25:09 UTC
  • mto: This revision was merged to the branch mainline in revision 5483.
  • Revision ID: mbp@sourcefrog.net-20101008092509-ww1ij1a0aqqpcbdj
List variations within the test classes, rather than in load_tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
53
53
from bzrlib.tests.variations import (
54
54
    TestVariation,
55
55
    multiply_tests_by_variations,
 
56
    multiply_tests_by_their_variations,
56
57
    )
57
58
from bzrlib.transport import (
58
59
    http,
164
165
                TestHttpTransportUrls,
165
166
                Test_redirected_to,
166
167
                )))
167
 
    multiply_tests_by_variations(
168
 
        t_tests, [VaryByHttpClientImplementation()], result)
 
168
    multiply_tests_by_their_variations(t_tests, result)
169
169
 
170
170
    # some tests are parametrized by the protocol version only
171
171
    p_tests, remaining_tests = tests.split_suite_by_condition(
172
172
        remaining_tests, tests.condition_isinstance((
173
173
                TestAuthOnRedirected,
174
174
                )))
175
 
    multiply_tests_by_variations(
176
 
        p_tests, [VaryByHttpProtocolVersion()], result)
 
175
    multiply_tests_by_their_variations(p_tests, result)
177
176
 
178
177
    # each implementation tested with each HTTP version
179
178
    tp_tests, remaining_tests = tests.split_suite_by_condition(
189
188
                TestRanges,
190
189
                TestSpecificRequestHandler,
191
190
                )))
192
 
    multiply_tests_by_variations(
193
 
        tp_tests, [
194
 
            VaryByHttpClientImplementation(),
195
 
            VaryByHttpProtocolVersion(),
196
 
        ],
197
 
        result)
 
191
    multiply_tests_by_their_variations(tp_tests, result) 
198
192
 
199
193
    # proxy auth: each auth scheme on all http versions on all implementations.
200
194
    tppa_tests, remaining_tests = tests.split_suite_by_condition(
201
195
        remaining_tests, tests.condition_isinstance((
202
196
                TestProxyAuth,
203
197
                )))
204
 
    multiply_tests_by_variations(
205
 
        tppa_tests, [
206
 
            VaryByHttpClientImplementation(),
207
 
            VaryByHttpProtocolVersion(),
208
 
            VaryByHttpProxyAuthScheme(),
209
 
        ], result)
 
198
    multiply_tests_by_their_variations(tppa_tests, result)
210
199
 
211
200
    # auth: each auth scheme on all http versions on all implementations.
212
201
    tpa_tests, remaining_tests = tests.split_suite_by_condition(
213
202
        remaining_tests, tests.condition_isinstance((
214
203
                TestAuth,
215
204
                )))
216
 
    multiply_tests_by_variations(
217
 
        tpa_tests, [
218
 
            VaryByHttpClientImplementation(),
219
 
            VaryByHttpProtocolVersion(),
220
 
            VaryByHttpAuthScheme(),
221
 
        ], result)
 
205
    multiply_tests_by_their_variations(tpa_tests, result)
222
206
 
223
207
    # activity: on all http[s] versions on all implementations
224
208
    tpact_tests, remaining_tests = tests.split_suite_by_condition(
225
209
        remaining_tests, tests.condition_isinstance((
226
210
                TestActivity,
227
211
                )))
228
 
    multiply_tests_by_variations(
229
 
        tpact_tests, [
230
 
            VaryByHttpActivity(),
231
 
            VaryByHttpProtocolVersion(),
232
 
        ], result)
 
212
    multiply_tests_by_their_variations(tpact_tests, result) 
233
213
 
234
214
    # No parametrization for the remaining tests
235
215
    result.addTests(remaining_tests)
443
423
 
444
424
 
445
425
class TestHttpTransportUrls(tests.TestCase):
 
426
 
446
427
    """Test the http urls."""
447
428
 
 
429
    variations = [VaryByHttpClientImplementation()]
 
430
 
448
431
    def test_abs_url(self):
449
432
        """Construction of absolute http URLs"""
450
433
        t = self._transport('http://bazaar-vcs.org/bzr/bzr.dev/')
519
502
class TestHTTPConnections(http_utils.TestCaseWithWebserver):
520
503
    """Test the http connections."""
521
504
 
 
505
    variations = [
 
506
        VaryByHttpClientImplementation(), 
 
507
        VaryByHttpProtocolVersion(),
 
508
        ]
 
509
 
522
510
    def setUp(self):
523
511
        http_utils.TestCaseWithWebserver.setUp(self)
524
512
        self.build_tree(['foo/', 'foo/bar'], line_endings='binary',
569
557
class TestHttpTransportRegistration(tests.TestCase):
570
558
    """Test registrations of various http implementations"""
571
559
 
 
560
    variations = [VaryByHttpClientImplementation()]
 
561
 
572
562
    def test_http_registered(self):
573
563
        t = transport.get_transport('%s://foo.com/' % self._url_protocol)
574
564
        self.assertIsInstance(t, transport.Transport)
577
567
 
578
568
class TestPost(tests.TestCase):
579
569
 
 
570
    variations = [
 
571
        VaryByHttpClientImplementation(), 
 
572
        VaryByHttpProtocolVersion(),
 
573
        ]
 
574
 
580
575
    def test_post_body_is_received(self):
581
576
        server = RecordingServer(expect_body_tail='end-of-body',
582
577
                                 scheme=self._url_protocol)
629
624
    Daughter classes are expected to override _req_handler_class
630
625
    """
631
626
 
 
627
    variations = [
 
628
        VaryByHttpClientImplementation(), 
 
629
        VaryByHttpProtocolVersion(),
 
630
        ]
 
631
 
632
632
    # Provide a useful default
633
633
    _req_handler_class = http_server.TestingHTTPRequestHandler
634
634
 
1099
1099
class TestLimitedRangeRequestServer(http_utils.TestCaseWithWebserver):
1100
1100
    """Tests readv requests against a server erroring out on too much ranges."""
1101
1101
 
 
1102
    variations = [
 
1103
        VaryByHttpClientImplementation(), 
 
1104
        VaryByHttpProtocolVersion(),
 
1105
        ]
 
1106
 
1102
1107
    # Requests with more range specifiers will error out
1103
1108
    range_limit = 3
1104
1109
 
1178
1183
    to the file names).
1179
1184
    """
1180
1185
 
 
1186
    variations = [
 
1187
        VaryByHttpClientImplementation(), 
 
1188
        VaryByHttpProtocolVersion(),
 
1189
        ]
 
1190
 
1181
1191
    # FIXME: We don't have an https server available, so we don't
1182
1192
    # test https connections. --vila toolongago
1183
1193
 
1280
1290
class TestRanges(http_utils.TestCaseWithWebserver):
1281
1291
    """Test the Range header in GET methods."""
1282
1292
 
 
1293
    variations = [
 
1294
        VaryByHttpClientImplementation(), 
 
1295
        VaryByHttpProtocolVersion(),
 
1296
        ]
 
1297
 
1283
1298
    def setUp(self):
1284
1299
        http_utils.TestCaseWithWebserver.setUp(self)
1285
1300
        self.build_tree_contents([('a', '0123456789')],)
1325
1340
class TestHTTPRedirections(http_utils.TestCaseWithRedirectedWebserver):
1326
1341
    """Test redirection between http servers."""
1327
1342
 
 
1343
    variations = [
 
1344
        VaryByHttpClientImplementation(), 
 
1345
        VaryByHttpProtocolVersion(),
 
1346
        ]
 
1347
 
1328
1348
    def setUp(self):
1329
1349
        super(TestHTTPRedirections, self).setUp()
1330
1350
        self.build_tree_contents([('a', '0123456789'),
1393
1413
    -- vila 20070212
1394
1414
    """
1395
1415
 
 
1416
    variations = [
 
1417
        VaryByHttpClientImplementation(), 
 
1418
        VaryByHttpProtocolVersion(),
 
1419
        ]
 
1420
 
1396
1421
    def setUp(self):
1397
1422
        if (features.pycurl.available()
1398
1423
            and self._transport == PyCurlTransport):
1443
1468
class TestDoCatchRedirections(http_utils.TestCaseWithRedirectedWebserver):
1444
1469
    """Test transport.do_catching_redirections."""
1445
1470
 
 
1471
    variations = [
 
1472
        VaryByHttpClientImplementation(), 
 
1473
        VaryByHttpProtocolVersion(),
 
1474
        ]
 
1475
 
1446
1476
    def setUp(self):
1447
1477
        super(TestDoCatchRedirections, self).setUp()
1448
1478
        self.build_tree_contents([('a', '0123456789'),],)
1490
1520
class TestAuth(http_utils.TestCaseWithWebserver):
1491
1521
    """Test authentication scheme"""
1492
1522
 
 
1523
    variations = [
 
1524
        VaryByHttpClientImplementation(),
 
1525
        VaryByHttpProtocolVersion(),
 
1526
        VaryByHttpAuthScheme(),
 
1527
        ]
 
1528
 
1493
1529
    _auth_header = 'Authorization'
1494
1530
    _password_prompt_prefix = ''
1495
1531
    _username_prompt_prefix = ''
1699
1735
class TestProxyAuth(TestAuth):
1700
1736
    """Test proxy authentication schemes."""
1701
1737
 
 
1738
    variations = [
 
1739
        VaryByHttpClientImplementation(),
 
1740
        VaryByHttpProtocolVersion(),
 
1741
        VaryByHttpProxyAuthScheme(),
 
1742
        ]
 
1743
 
1702
1744
    _auth_header = 'Proxy-authorization'
1703
1745
    _password_prompt_prefix = 'Proxy '
1704
1746
    _username_prompt_prefix = 'Proxy '
1760
1802
 
1761
1803
class SmartHTTPTunnellingTest(tests.TestCaseWithTransport):
1762
1804
 
 
1805
    variations = [
 
1806
        VaryByHttpClientImplementation(), 
 
1807
        VaryByHttpProtocolVersion(),
 
1808
        ]
 
1809
 
1763
1810
    def setUp(self):
1764
1811
        super(SmartHTTPTunnellingTest, self).setUp()
1765
1812
        # We use the VFS layer as part of HTTP tunnelling tests.
1854
1901
 
1855
1902
class Test_redirected_to(tests.TestCase):
1856
1903
 
 
1904
    variations = [VaryByHttpClientImplementation()]
 
1905
 
1857
1906
    def test_redirected_to_subdir(self):
1858
1907
        t = self._transport('http://www.example.com/foo')
1859
1908
        r = t._redirected_to('http://www.example.com/foo',
1967
2016
    be able to predict the activity on the client socket.
1968
2017
    """
1969
2018
 
 
2019
    variations = [
 
2020
        VaryByHttpActivity(),
 
2021
        VaryByHttpProtocolVersion(),
 
2022
        ]
 
2023
 
1970
2024
    def setUp(self):
1971
2025
        tests.TestCase.setUp(self)
1972
2026
        self.server = self._activity_server(self._protocol_version)
2131
2185
class TestAuthOnRedirected(http_utils.TestCaseWithRedirectedWebserver):
2132
2186
    """Test authentication on the redirected http server."""
2133
2187
 
 
2188
    variations = [VaryByHttpProtocolVersion()]
 
2189
 
2134
2190
    _auth_header = 'Authorization'
2135
2191
    _password_prompt_prefix = ''
2136
2192
    _username_prompt_prefix = ''