/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
5809.3.3 by Aaron Bentley
Test directories.
1
# Copyright (C) 2011 Canonical Ltd
5809.3.1 by Aaron Bentley
Switch to iter_entries_by_dir.
2
#
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
7
#
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
# GNU General Public License for more details.
12
#
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
5809.3.5 by Aaron Bentley
Remove unused code.
17
import os
5809.3.3 by Aaron Bentley
Test directories.
18
import tarfile
5809.3.1 by Aaron Bentley
Switch to iter_entries_by_dir.
19
20
from bzrlib.export import export
5809.3.5 by Aaron Bentley
Remove unused code.
21
from bzrlib import tests
5809.3.1 by Aaron Bentley
Switch to iter_entries_by_dir.
22
from bzrlib.tests.per_tree import TestCaseWithTree
23
24
25
class TestExport(TestCaseWithTree):
26
27
    def test_export_tar(self):
28
        work_a = self.make_branch_and_tree('wta')
5809.3.3 by Aaron Bentley
Test directories.
29
        self.build_tree_contents(
30
            [('wta/file', 'a\nb\nc\nd\n'), ('wta/dir', '')])
5809.3.2 by Aaron Bentley
Support PreviewTree.has_filename.
31
        work_a.add('file', 'file-id')
5809.3.3 by Aaron Bentley
Test directories.
32
        work_a.add('dir', 'dir-id')
5809.3.2 by Aaron Bentley
Support PreviewTree.has_filename.
33
        work_a.commit('add file')
5809.3.3 by Aaron Bentley
Test directories.
34
        tree_a = self.workingtree_to_test_tree(work_a)
35
        export(tree_a, 'output', 'tar')
36
        tf = tarfile.open('output')
37
        names = tf.getnames()
38
        self.assertIn('output/file', names)
39
        self.assertIn('output/dir', names)
5809.3.4 by Aaron Bentley
Add symlink testing.
40
41
    def test_export_tar_symlink(self):
42
        self.requireFeature(tests.SymlinkFeature)
43
        work_a = self.make_branch_and_tree('wta')
44
        os.symlink('target', 'wta/link')
45
        work_a.add('link', 'link-id')
46
        work_a.commit('add link')
47
        tree_a = self.workingtree_to_test_tree(work_a)
48
        export(tree_a, 'output', 'tar')
49
        tf = tarfile.open('output')
50
        names = tf.getnames()
51
        self.assertIn('output/link', names)