~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/tree_implementations/test_inv.py

  • Committer: Mark Hammond
  • Date: 2008-11-17 06:27:20 UTC
  • mto: (3932.3.1 cicp-1.11)
  • mto: This revision was merged to the branch mainline in revision 3937.
  • Revision ID: mhammond@skippinet.com.au-20081117062720-2xbtytksggumj1sd
 Add get_canonical_path method to the Tree class, plus tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
124
124
        self.addCleanup(tree.unlock)
125
125
        self.assertEqual(set([]), tree.paths2ids(['file'],
126
126
                         require_versioned=False))
 
127
 
 
128
    def test_canonical_path(self):
 
129
        work_tree = self.make_branch_and_tree('tree')
 
130
        self.build_tree(['tree/dir/', 'tree/dir/file'])
 
131
        work_tree.add(['dir', 'dir/file'])
 
132
        work_tree.commit('commit 1')
 
133
        self.assertEqual(work_tree.get_canonical_path('Dir/File'), 'dir/file')
 
134
 
 
135
    def test_canonical_path_root(self):
 
136
        work_tree = self.make_branch_and_tree('tree')
 
137
        self.build_tree(['tree/dir/', 'tree/dir/file'])
 
138
        work_tree.add(['dir', 'dir/file'])
 
139
        work_tree.commit('commit 1')
 
140
        self.assertEqual(work_tree.get_canonical_path(''), '')
 
141
        self.assertEqual(work_tree.get_canonical_path('/'), '/')
 
142
 
 
143
    def test_canonical_path_invalid_all(self):
 
144
        work_tree = self.make_branch_and_tree('tree')
 
145
        self.build_tree(['tree/dir/', 'tree/dir/file'])
 
146
        work_tree.add(['dir', 'dir/file'])
 
147
        work_tree.commit('commit 1')
 
148
        self.assertEqual(work_tree.get_canonical_path('foo/bar'), 'foo/bar')
 
149
 
 
150
    def test_canonical_invalid_child(self):
 
151
        work_tree = self.make_branch_and_tree('tree')
 
152
        self.build_tree(['tree/dir/', 'tree/dir/file'])
 
153
        work_tree.add(['dir', 'dir/file'])
 
154
        work_tree.commit('commit 1')
 
155
        self.assertEqual(work_tree.get_canonical_path('Dir/None'), 'dir/None')