~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_intertree/test_file_content_matches.py

Merge bzr.dev, update to use new hooks.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2011 Canonical Ltd
 
2
#
 
3
# This program is free software; you can redistribute it and/or modify
 
4
# it under the terms of the GNU General Public License as published by
 
5
# the Free Software Foundation; either version 2 of the License, or
 
6
# (at your option) any later version.
 
7
#
 
8
# This program is distributed in the hope that it will be useful,
 
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
# GNU General Public License for more details.
 
12
#
 
13
# You should have received a copy of the GNU General Public License
 
14
# along with this program; if not, write to the Free Software
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
16
 
 
17
"""Tests for the InterTree.file_content_matches() function."""
 
18
 
 
19
from bzrlib.tests.per_intertree import TestCaseWithTwoTrees
 
20
 
 
21
 
 
22
class TestFileContentMatches(TestCaseWithTwoTrees):
 
23
 
 
24
    def test_same_contents_and_verifier(self):
 
25
        tree1 = self.make_branch_and_tree('1')
 
26
        tree2 = self.make_to_branch_and_tree('2')
 
27
        self.build_tree_contents([
 
28
            ('1/file', 'apples'),
 
29
            ('2/file', 'apples'),
 
30
            ])
 
31
        tree1.add('file', 'file-id-1')
 
32
        tree2.add('file', 'file-id-2')
 
33
        tree1, tree2 = self.mutable_trees_to_test_trees(self, tree1, tree2)
 
34
        inter = self.intertree_class(tree1, tree2)
 
35
        self.assertTrue(inter.file_content_matches('file-id-1', 'file-id-2'))
 
36
 
 
37
    def test_different_contents_and_same_verifier(self):
 
38
        tree1 = self.make_branch_and_tree('1')
 
39
        tree2 = self.make_to_branch_and_tree('2')
 
40
        self.build_tree_contents([
 
41
            ('1/file', 'apples'),
 
42
            ('2/file', 'oranges'),
 
43
            ])
 
44
        tree1.add('file', 'file-id-1')
 
45
        tree2.add('file', 'file-id-2')
 
46
        tree1, tree2 = self.mutable_trees_to_test_trees(self, tree1, tree2)
 
47
        inter = self.intertree_class(tree1, tree2)
 
48
        self.assertFalse(inter.file_content_matches('file-id-1', 'file-id-2'))