~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_read_bundle.py

  • Committer: Martin Pool
  • Date: 2007-04-04 01:22:11 UTC
  • mfrom: (2393.1.1 bzr.docs)
  • mto: This revision was merged to the branch mainline in revision 2397.
  • Revision ID: mbp@sourcefrog.net-20070404012211-sq269me6bai9m6xk
merge trunk and doc fix from elliot

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
        return bzrlib.urlutils.join(self._server.get_url(), relpath)
38
38
 
39
39
    def create_test_bundle(self):
40
 
        # Can't use self.get_transport() because that asserts that 
41
 
        # it is not readonly, so just skip tests where the server is readonly
42
 
        self._transport = self.get_transport()
43
 
        #if isinstance(self._transport, MemoryTransport):
44
 
        #    return None
45
40
        self.build_tree(['tree/', 'tree/a', 'tree/subdir/'])
46
41
 
47
42
        format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
48
43
 
49
 
 
50
44
        bzrdir = format.initialize('tree')
51
45
        repo = bzrdir.create_repository()
52
46
        branch = repo.bzrdir.create_branch()
59
53
        rev_ids = write_bundle(wt.branch.repository,
60
54
                               wt.get_parent_ids()[0], None, out)
61
55
        out.seek(0)
62
 
        if self._transport.is_readonly():
 
56
        if self.get_transport().is_readonly():
63
57
            f = open('test_bundle', 'wb')
64
58
            f.write(out.getvalue())
65
59
            f.close()
66
60
        else:
67
 
            self._transport.put_file('test_bundle', out)
 
61
            self.get_transport().put_file('test_bundle', out)
68
62
            self.log('Put to: %s', self.get_url('test_bundle'))
69
63
        return wt
70
64
 
71
65
    def test_read_bundle_from_url(self):
 
66
        self._captureVar('NO_SMART_VFS', None)
72
67
        wt = self.create_test_bundle()
73
68
        if wt is None:
74
69
            return
75
 
 
76
70
        info = bzrlib.bundle.read_bundle_from_url(
77
71
                    unicode(self.get_url('test_bundle')))
78
72
        bundle_tree = info.revision_tree(wt.branch.repository, info.target)
81
75
    def test_read_fail(self):
82
76
        # Trying to read from a directory, or non-bundle file
83
77
        # should fail with NotABundle
 
78
        self._captureVar('NO_SMART_VFS', None)
84
79
        wt = self.create_test_bundle()
85
80
        if wt is None:
86
81
            return