~jelmer/brz/smart-add-illegal-char

« back to all changes in this revision

Viewing changes to breezy/tests/per_tree/test_ids.py

  • Committer: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2018-09-22 01:20:57 UTC
  • mfrom: (7122.4.1 nomore-invtree)
  • Revision ID: breezy.the.bot@gmail.com-20180922012057-ztd75ad3ums5wbfh
Some refactoring; check for features rather than a specific implementation (InventoryTree).

Merged from https://code.launchpad.net/~jelmer/brz/nomore-invtree/+merge/355137

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
from breezy import (
18
18
    errors,
19
 
)
 
19
    tests,
 
20
    )
20
21
from breezy.tests.per_tree import TestCaseWithTree
21
22
 
22
23
 
23
 
class IdTests(TestCaseWithTree):
 
24
class Path2IdTests(TestCaseWithTree):
24
25
 
25
26
    def setUp(self):
26
 
        super(IdTests, self).setUp()
 
27
        super(Path2IdTests, self).setUp()
27
28
        work_a = self.make_branch_and_tree('wta')
28
29
        if not work_a.supports_setting_file_ids():
29
30
            self.skipTest("working tree does not support setting file ids")
52
53
        self.assertEqual('dir', self.tree_a.id2path(b'dir-id'))
53
54
        self.assertEqual('dir/file', self.tree_a.id2path(b'file-id'))
54
55
        self.assertRaises(errors.NoSuchId, self.tree_a.id2path, b'nonexistant')
 
56
 
 
57
class Path2IdsTests(TestCaseWithTree):
 
58
 
 
59
    def test_paths2ids_recursive(self):
 
60
        work_tree = self.make_branch_and_tree('tree')
 
61
        self.build_tree(['tree/dir/', 'tree/dir/file'])
 
62
        work_tree.add(['dir', 'dir/file'])
 
63
        if not work_tree.supports_setting_file_ids():
 
64
            raise tests.TestNotApplicable(
 
65
                "test not applicable on non-inventory tests")
 
66
        tree = self._convert_tree(work_tree)
 
67
        tree.lock_read()
 
68
        self.addCleanup(tree.unlock)
 
69
        self.assertEqual({tree.path2id('dir'), tree.path2id('dir/file')},
 
70
                         tree.paths2ids(['dir']))
 
71
 
 
72
    def test_paths2ids_forget_old(self):
 
73
        work_tree = self.make_branch_and_tree('tree')
 
74
        self.build_tree(['tree/file'])
 
75
        work_tree.add('file')
 
76
        work_tree.commit('commit old state')
 
77
        work_tree.remove('file')
 
78
        if not work_tree.supports_setting_file_ids():
 
79
            raise tests.TestNotApplicable(
 
80
                "test not applicable on non-inventory tests")
 
81
        tree = self._convert_tree(work_tree)
 
82
        tree.lock_read()
 
83
        self.addCleanup(tree.unlock)
 
84
        self.assertEqual(set([]), tree.paths2ids(['file'],
 
85
                         require_versioned=False))