/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
5906.1.8 by Jelmer Vernooij
Tests.
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
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
19
from breezy.tests.per_intertree import TestCaseWithTwoTrees
5906.1.8 by Jelmer Vernooij
Tests.
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([
6855.4.1 by Jelmer Vernooij
Yet more bees.
28
            ('1/file', b'apples'),
29
            ('2/file', b'apples'),
5906.1.8 by Jelmer Vernooij
Tests.
30
            ])
6855.4.1 by Jelmer Vernooij
Yet more bees.
31
        tree1.add('file', b'file-id-1')
32
        tree2.add('file', b'file-id-2')
5906.1.8 by Jelmer Vernooij
Tests.
33
        tree1, tree2 = self.mutable_trees_to_test_trees(self, tree1, tree2)
34
        inter = self.intertree_class(tree1, tree2)
6883.7.1 by Jelmer Vernooij
Swap order of arguments to Tree.file_content_matches.
35
        self.assertTrue(inter.file_content_matches('file', 'file'))
5906.1.8 by Jelmer Vernooij
Tests.
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([
6855.4.1 by Jelmer Vernooij
Yet more bees.
41
            ('1/file', b'apples'),
42
            ('2/file', b'oranges'),
5906.1.8 by Jelmer Vernooij
Tests.
43
            ])
6855.4.1 by Jelmer Vernooij
Yet more bees.
44
        tree1.add('file', b'file-id-1')
45
        tree2.add('file', b'file-id-2')
5906.1.8 by Jelmer Vernooij
Tests.
46
        tree1, tree2 = self.mutable_trees_to_test_trees(self, tree1, tree2)
47
        inter = self.intertree_class(tree1, tree2)
6883.1.1 by Jelmer Vernooij
Avoid file id lookups.
48
        self.assertFalse(inter.file_content_matches(
6883.1.3 by Jelmer Vernooij
Add test, make file_id optional.
49
            'file', 'file'))