~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_read_bundle.py

  • Committer: John Arbash Meinel
  • Date: 2010-02-10 17:52:08 UTC
  • mfrom: (5021 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5023.
  • Revision ID: john@arbash-meinel.com-20100210175208-bubuwav4uqigu291
Merge bzr.dev 5021 to resolve NEWS

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2011 Canonical Ltd
 
1
# Copyright (C) 2006 Canonical Ltd
2
2
#
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."""
18
18
 
19
19
import cStringIO
 
20
import os
20
21
 
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
31
 
 
32
 
 
33
 
load_tests = load_tests_apply_scenarios
 
33
 
 
34
 
 
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(),
 
40
        remaining_tests)
34
41
 
35
42
 
36
43
def create_bundle_file(test_case):
53
60
    return out, wt
54
61
 
55
62
 
56
 
class TestReadMergeableBundleFromURL(TestTransportImplementation):
 
63
class TestDeprecations(tests.TestCaseInTempDir):
 
64
 
 
65
    def create_test_bundle(self):
 
66
        out, wt = create_bundle_file(self)
 
67
        f = open('test_bundle', 'wb')
 
68
        try:
 
69
            f.write(out.getvalue())
 
70
        finally:
 
71
            f.close()
 
72
        return wt
 
73
 
 
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,
 
81
                            url)
 
82
 
 
83
 
 
84
class TestReadBundleFromURL(TestTransportImplementation):
57
85
    """Test that read_bundle works properly across multiple transports"""
58
86
 
59
 
    scenarios = transport_test_permutations()
60
 
 
61
87
    def setUp(self):
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()
71
97
 
72
98
    def read_mergeable_from_url(self, url):