1
# Copyright (C) 2006-2011 Canonical Ltd
1
# Copyright (C) 2006 Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
17
17
"""Test read_bundle works properly across various transports."""
21
22
import bzrlib.bundle
22
23
from bzrlib.bundle.serializer import write_bundle
23
24
import bzrlib.bzrdir
24
25
import bzrlib.errors as errors
26
from bzrlib.symbol_versioning import deprecated_in
25
27
from bzrlib import tests
26
28
from bzrlib.tests.test_transport import TestTransportImplementation
27
29
from bzrlib.tests.per_transport import transport_test_permutations
28
30
import bzrlib.transport
31
from bzrlib.transport.memory import MemoryTransport
29
32
import bzrlib.urlutils
30
from bzrlib.tests.scenarios import load_tests_apply_scenarios
33
load_tests = load_tests_apply_scenarios
35
def load_tests(standard_tests, module, loader):
36
"""Multiply tests for tranport implementations."""
37
transport_tests, remaining_tests = tests.split_suite_by_condition(
38
standard_tests, tests.condition_isinstance(TestReadBundleFromURL))
39
return tests.multiply_tests(transport_tests, transport_test_permutations(),
36
43
def create_bundle_file(test_case):
56
class TestReadMergeableBundleFromURL(TestTransportImplementation):
63
class TestDeprecations(tests.TestCaseInTempDir):
65
def create_test_bundle(self):
66
out, wt = create_bundle_file(self)
67
f = open('test_bundle', 'wb')
69
f.write(out.getvalue())
74
def test_read_bundle_from_url_deprecated(self):
75
wt = self.create_test_bundle()
76
t = bzrlib.transport.get_transport(self.test_dir)
77
url = t.abspath('test_bundle')
78
self.callDeprecated([deprecated_in((1, 12, 0))
79
% 'bzrlib.bundle.read_bundle_from_url'],
80
bzrlib.bundle.read_bundle_from_url,
84
class TestReadBundleFromURL(TestTransportImplementation):
57
85
"""Test that read_bundle works properly across multiple transports"""
59
scenarios = transport_test_permutations()
62
super(TestReadMergeableBundleFromURL, self).setUp()
88
super(TestReadBundleFromURL, self).setUp()
63
89
self.bundle_name = 'test_bundle'
64
90
# read_mergeable_from_url will invoke get_transport which may *not*
65
91
# respect self._transport (i.e. returns a transport that is different
66
92
# from the one we want to test, so we must inject a correct transport
67
93
# into possible_transports first).
68
94
self.possible_transports = [self.get_transport(self.bundle_name)]
69
self.overrideEnv('BZR_NO_SMART_VFS', None)
95
self._captureVar('BZR_NO_SMART_VFS', None)
70
96
wt = self.create_test_bundle()
72
98
def read_mergeable_from_url(self, url):