~bzr-pqm/bzr/bzr.dev

1399.1.12 by Robert Collins
add new test script
1
# (C) 2005 Canonical Ltd
2
# Authors:  Robert Collins <robert.collins@canonical.com>
3
#
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.
8
#
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.
13
#
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
17
18
import os
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
23
24
class TestTreeDirectory(TestCaseInTempDir):
25
26
    def test_kind_character(self):
27
        self.assertEqual(TreeDirectory().kind_character(), '/')
28
29
30
class TestTreeEntry(TestCaseInTempDir):
31
32
    def test_kind_character(self):
33
        self.assertEqual(TreeEntry().kind_character(), '???')
34
35
36
class TestTreeFile(TestCaseInTempDir):
37
38
    def test_kind_character(self):
39
        self.assertEqual(TreeFile().kind_character(), '')
40
41
42
class TestTreeLink(TestCaseInTempDir):
43
44
    def test_kind_character(self):
45
        self.assertEqual(TreeLink().kind_character(), '')
46
47
48
class TestWorkingTree(TestCaseInTempDir):
49
50
    def test_listfiles(self):
51
        branch = Branch.initialize('.')
52
        os.mkdir('dir')
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()))