1
# (C) 2005 Canonical Ltd
2
# Authors: Robert Collins <robert.collins@canonical.com>
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 2 of the License, or
7
# (at your option) any later version.
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
# GNU General Public License for more details.
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
from bzrlib.branch import Branch
20
from bzrlib.selftest import TestCaseInTempDir
21
from bzrlib.trace import mutter
22
from bzrlib.workingtree import TreeEntry, TreeDirectory, TreeFile, TreeLink
24
class TestTreeDirectory(TestCaseInTempDir):
26
def test_kind_character(self):
27
self.assertEqual(TreeDirectory().kind_character(), '/')
30
class TestTreeEntry(TestCaseInTempDir):
32
def test_kind_character(self):
33
self.assertEqual(TreeEntry().kind_character(), '???')
36
class TestTreeFile(TestCaseInTempDir):
38
def test_kind_character(self):
39
self.assertEqual(TreeFile().kind_character(), '')
42
class TestTreeLink(TestCaseInTempDir):
44
def test_kind_character(self):
45
self.assertEqual(TreeLink().kind_character(), '')
48
class TestWorkingTree(TestCaseInTempDir):
50
def test_listfiles(self):
51
branch = Branch.initialize('.')
53
print >> open('file', 'w'), "content"
54
os.symlink('target', 'symlink')
55
tree = branch.working_tree()
56
files = list(tree.list_files())
57
self.assertEqual(files[0], ('dir', '?', 'directory', None, TreeDirectory()))
58
self.assertEqual(files[1], ('file', '?', 'file', None, TreeFile()))
59
self.assertEqual(files[2], ('symlink', '?', 'symlink', None, TreeLink()))