~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_read_bundle.py

  • Committer: Alexander Belchenko
  • Date: 2006-07-31 16:12:57 UTC
  • mto: (1711.2.111 jam-integration)
  • mto: This revision was merged to the branch mainline in revision 1906.
  • Revision ID: bialix@ukr.net-20060731161257-91a231523255332c
new official bzr.ico

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006 Canonical Ltd
 
1
# Copyright (C) 2006 by 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
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
40
45
        self.build_tree(['tree/', 'tree/a', 'tree/subdir/'])
41
46
 
42
47
        format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
43
48
 
 
49
 
44
50
        bzrdir = format.initialize('tree')
45
51
        repo = bzrdir.create_repository()
46
52
        branch = repo.bzrdir.create_branch()
51
57
 
52
58
        out = cStringIO.StringIO()
53
59
        rev_ids = write_bundle(wt.branch.repository,
54
 
                               wt.get_parent_ids()[0], 'null:', out)
 
60
                               wt.last_revision(), None, out)
55
61
        out.seek(0)
56
 
        if self.get_transport().is_readonly():
 
62
        if self._transport.is_readonly():
57
63
            f = open('test_bundle', 'wb')
58
64
            f.write(out.getvalue())
59
65
            f.close()
60
66
        else:
61
 
            self.get_transport().put_file('test_bundle', out)
 
67
            self._transport.put('test_bundle', out)
62
68
            self.log('Put to: %s', self.get_url('test_bundle'))
63
69
        return wt
64
70
 
65
71
    def test_read_bundle_from_url(self):
66
 
        self._captureVar('BZR_NO_SMART_VFS', None)
67
72
        wt = self.create_test_bundle()
68
73
        if wt is None:
69
74
            return
 
75
 
70
76
        info = bzrlib.bundle.read_bundle_from_url(
71
 
                    unicode(self.get_url('test_bundle')))
72
 
        revision = info.real_revisions[-1]
73
 
        self.assertEqual('commit-1', revision.revision_id)
 
77
                    self.get_url('test_bundle'))
 
78
        bundle_tree = info.revision_tree(wt.branch.repository, info.target)
 
79
        self.assertEqual('commit-1', bundle_tree.revision_id)
74
80
 
75
81
    def test_read_fail(self):
76
82
        # Trying to read from a directory, or non-bundle file
77
83
        # should fail with NotABundle
78
 
        self._captureVar('BZR_NO_SMART_VFS', None)
79
84
        wt = self.create_test_bundle()
80
85
        if wt is None:
81
86
            return