/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/tests/test_tree.py

  • Committer: Jelmer Vernooij
  • Date: 2018-09-29 22:41:11 UTC
  • mto: This revision was merged to the branch mainline in revision 7135.
  • Revision ID: jelmer@jelmer.uk-20180929224111-7usahuxndu0saqmj
Fix get_canonical_path and add some basic tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
    FileTimestampUnavailable,
30
30
    InterTree,
31
31
    find_previous_paths,
 
32
    get_canonical_path,
32
33
    )
33
34
 
34
35
 
461
462
 
462
463
        self.assertEqual({'c': 'b', 'b': None},
463
464
                         find_previous_paths(tree2, tree1, ['b', 'c']))
 
465
 
 
466
 
 
467
class GetCanonicalPath(TestCaseWithTransport):
 
468
 
 
469
    def test_existing_case(self):
 
470
        # Test that we can find a file from a path with different case
 
471
        tree = self.make_branch_and_tree('tree')
 
472
        self.build_tree(['tree/b'])
 
473
        tree.add(['b'])
 
474
        self.assertEqual(
 
475
                'b',
 
476
                get_canonical_path(tree, 'b', lambda x: x.lower()))
 
477
        self.assertEqual(
 
478
                'b',
 
479
                get_canonical_path(tree, 'B', lambda x: x.lower()))
 
480
 
 
481
    def test_nonexistant_preserves_case(self):
 
482
        tree = self.make_branch_and_tree('tree')
 
483
        self.assertEqual(
 
484
                'b',
 
485
                get_canonical_path(tree, 'b', lambda x: x.lower()))
 
486
        self.assertEqual(
 
487
                'B',
 
488
                get_canonical_path(tree, 'B', lambda x: x.lower()))
 
489
 
 
490
    def test_in_directory_with_case(self):
 
491
        tree = self.make_branch_and_tree('tree')
 
492
        self.build_tree(['tree/a/', 'tree/a/b'])
 
493
        tree.add(['a', 'a/b'])
 
494
        self.assertEqual(
 
495
                'a/b',
 
496
                get_canonical_path(tree, 'a/b', lambda x: x.lower()))
 
497
        self.assertEqual(
 
498
                'a/b',
 
499
                get_canonical_path(tree, 'A/B', lambda x: x.lower()))
 
500
        self.assertEqual(
 
501
                'a/b',
 
502
                get_canonical_path(tree, 'A/b', lambda x: x.lower()))
 
503
        self.assertEqual(
 
504
                'a/C',
 
505
                get_canonical_path(tree, 'A/C', lambda x: x.lower()))