~bzr-pqm/bzr/bzr.dev

6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
1
# Copyright (C) 2009, 2010, 2016 Canonical Ltd
3978.3.16 by Jelmer Vernooij
Add some smoke tests for BzrDir.push_branch().
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 bzrdir implementations - push."""
18
5363.2.2 by Jelmer Vernooij
Rename per_bzrdir => per_controldir.
19
from bzrlib.tests.per_controldir import (
5363.2.18 by Jelmer Vernooij
Rename TestCaseWithBzrDir -> TestCaseWithControlDir.
20
    TestCaseWithControlDir,
3978.3.16 by Jelmer Vernooij
Add some smoke tests for BzrDir.push_branch().
21
    )
22
23
5363.2.18 by Jelmer Vernooij
Rename TestCaseWithBzrDir -> TestCaseWithControlDir.
24
class TestPush(TestCaseWithControlDir):
3978.3.16 by Jelmer Vernooij
Add some smoke tests for BzrDir.push_branch().
25
26
    def create_simple_tree(self):
27
        tree = self.make_branch_and_tree('tree')
28
        self.build_tree(['tree/a'])
29
        tree.add(['a'], ['a-id'])
30
        tree.commit('one', rev_id='r1')
31
        return tree
32
4462.3.1 by Robert Collins
Whitespace cleanup.
33
    def test_push_new_branch(self):
3978.3.16 by Jelmer Vernooij
Add some smoke tests for BzrDir.push_branch().
34
        tree = self.create_simple_tree()
35
        dir = self.make_repository('dir').bzrdir
36
        result = dir.push_branch(tree.branch)
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
37
        self.assertEqual(tree.branch, result.source_branch)
38
        self.assertEqual(dir.open_branch().base, result.target_branch.base)
39
        self.assertEqual(dir.open_branch().base,
3978.3.16 by Jelmer Vernooij
Add some smoke tests for BzrDir.push_branch().
40
            tree.branch.get_push_location())
41
42
    def test_push_new_empty(self):
43
        tree = self.make_branch_and_tree('tree')
44
        dir = self.make_repository('dir').bzrdir
45
        result = dir.push_branch(tree.branch)
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
46
        self.assertEqual(tree.branch.base, result.source_branch.base)
47
        self.assertEqual(dir.open_branch().base,
3978.3.16 by Jelmer Vernooij
Add some smoke tests for BzrDir.push_branch().
48
            result.target_branch.base)
49
50
    def test_push_incremental(self):
51
        tree = self.create_simple_tree()
52
        dir = self.make_repository('dir').bzrdir
53
        dir.push_branch(tree.branch)
54
        self.build_tree(['tree/b'])
55
        tree.add(['b'])
56
        tree.commit('two', rev_id='r2')
57
        result = dir.push_branch(tree.branch)
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
58
        self.assertEqual(tree.last_revision(),
3978.3.16 by Jelmer Vernooij
Add some smoke tests for BzrDir.push_branch().
59
            result.branch_push_result.new_revid)
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
60
        self.assertEqual(2, result.branch_push_result.new_revno)
61
        self.assertEqual(tree.branch.base, result.source_branch.base)
62
        self.assertEqual(dir.open_branch().base, result.target_branch.base)