~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-08-05 16:51:01 UTC
  • mfrom: (5906.1.10 custom-verifier)
  • Revision ID: pqm@pqm.ubuntu.com-20110805165101-e89g9pgybm7db15a
(jelmer) Allow other kinds of file "verifiers" than SHA1. (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
303
303
        self.addCleanup(tree.unlock)
304
304
        expected = osutils.sha_strings('file content')
305
305
        self.assertEqual(expected, tree.get_file_sha1('file-id'))
 
306
 
 
307
 
 
308
class TestGetFileVerifier(TestCaseWithTree):
 
309
 
 
310
    def test_get_file_verifier(self):
 
311
        work_tree = self.make_branch_and_tree('tree')
 
312
        self.build_tree_contents([
 
313
            ('tree/file1', 'file content'),
 
314
            ('tree/file2', 'file content')])
 
315
        work_tree.add(['file1', 'file2'], ['file-id-1', 'file-id-2'])
 
316
        tree = self._convert_tree(work_tree)
 
317
        tree.lock_read()
 
318
        self.addCleanup(tree.unlock)
 
319
        (kind, data) = tree.get_file_verifier('file-id-1')
 
320
        self.assertEquals(
 
321
            tree.get_file_verifier('file-id-1'),
 
322
            tree.get_file_verifier('file-id-2'))
 
323
        if kind == "SHA1":
 
324
            expected = osutils.sha_strings('file content')
 
325
            self.assertEqual(expected, data)