~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Andrew Bennetts
  • Date: 2007-08-30 08:11:54 UTC
  • mfrom: (2766 +trunk)
  • mto: (2535.3.55 repo-refactor)
  • mto: This revision was merged to the branch mainline in revision 2772.
  • Revision ID: andrew.bennetts@canonical.com-20070830081154-16hebp2xwr15x2hc
Merge from bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
from bzrlib import (
18
18
    errors,
19
19
    tests,
 
20
    conflicts,
20
21
    )
21
22
from bzrlib.tests import TestSkipped
22
23
from bzrlib.tests.tree_implementations import TestCaseWithTree
119
120
            self.assertRaises(errors.NoSuchId, tree.id2path, 'a')
120
121
        finally:
121
122
            tree.unlock()
 
123
 
 
124
 
 
125
class TestExtractFilesBytes(TestCaseWithTree):
 
126
 
 
127
    def test_iter_files_bytes(self):
 
128
        work_tree = self.make_branch_and_tree('wt')
 
129
        self.build_tree_contents([('wt/foo', 'foo'),
 
130
                                  ('wt/bar', 'bar'),
 
131
                                  ('wt/baz', 'baz')])
 
132
        work_tree.add(['foo', 'bar', 'baz'], ['foo-id', 'bar-id', 'baz-id'])
 
133
        tree = self._convert_tree(work_tree)
 
134
        tree.lock_read()
 
135
        self.addCleanup(tree.unlock)
 
136
        extracted = dict((i, ''.join(b)) for i, b in
 
137
                         tree.iter_files_bytes([('foo-id', 'id1'),
 
138
                                                ('bar-id', 'id2'),
 
139
                                                ('baz-id', 'id3')]))
 
140
        self.assertEqual('foo', extracted['id1'])
 
141
        self.assertEqual('bar', extracted['id2'])
 
142
        self.assertEqual('baz', extracted['id3'])
 
143
        self.assertRaises(errors.NoSuchId, lambda: list(
 
144
                          tree.iter_files_bytes(
 
145
                          [('qux-id', 'file1-notpresent')])))
 
146
 
 
147
 
 
148
class TestConflicts(TestCaseWithTree):
 
149
 
 
150
    def test_conflicts(self):
 
151
        """Tree.conflicts() should return a ConflictList instance."""
 
152
        work_tree = self.make_branch_and_tree('wt')
 
153
        tree = self._convert_tree(work_tree)
 
154
        self.assertIsInstance(tree.conflicts(), conflicts.ConflictList)