239
240
self.addCleanup(tree.unlock)
240
241
self.assertEqual(expected, list(tree.extras()))
243
class TestHasId(TestCaseWithTree):
245
def test_has_id(self):
246
work_tree = self.make_branch_and_tree('tree')
247
self.build_tree(['tree/file'])
248
work_tree.add('file', 'file-id')
249
tree = self._convert_tree(work_tree)
251
self.addCleanup(tree.unlock)
252
self.assertTrue(tree.has_id('file-id'))
253
self.assertFalse(tree.has_id('dir-id'))
255
def test___contains__(self):
256
work_tree = self.make_branch_and_tree('tree')
257
self.build_tree(['tree/file'])
258
work_tree.add('file', 'file-id')
259
tree = self._convert_tree(work_tree)
261
self.addCleanup(tree.unlock)
262
self.assertTrue('file-id' in tree)
263
self.assertFalse('dir-id' in tree)
266
class TestGetFileSha1(TestCaseWithTree):
268
def test_get_file_sha1(self):
269
work_tree = self.make_branch_and_tree('tree')
270
self.build_tree_contents([('tree/file', 'file content')])
271
work_tree.add('file', 'file-id')
272
tree = self._convert_tree(work_tree)
274
self.addCleanup(tree.unlock)
275
expected = osutils.sha_strings('file content')
276
self.assertEqual(expected, tree.get_file_sha1('file-id'))