1
# Copyright (C) 2009, 2010 Canonical Ltd
1
# Copyright (C) 2009, 2010, 2011 Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
30
30
from bzrlib.tests import (
34
35
from bzrlib.tests.blackbox import test_push
37
def load_tests(standard_tests, module, loader):
38
"""Multiply tests for the dpush command."""
39
result = loader.suiteClass()
41
# one for each king of change
42
changes_tests, remaining_tests = tests.split_suite_by_condition(
43
standard_tests, tests.condition_isinstance((
44
TestDpushStrictWithChanges,
48
dict(_changes_type= '_uncommitted_changes')),
50
dict(_changes_type= '_pending_merges')),
52
dict(_changes_type= '_out_of_sync_trees')),
54
tests.multiply_tests(changes_tests, changes_scenarios, result)
55
# No parametrization for the remaining tests
56
result.addTests(remaining_tests)
61
class TestDpush(blackbox.ExternalBase):
36
from bzrlib.tests.scenarios import (
37
load_tests_apply_scenarios,
41
load_tests = load_tests_apply_scenarios
44
class TestDpush(tests.TestCaseWithTransport):
64
47
super(TestDpush, self).setUp()
86
69
self.build_tree(("dc/foo", "blaaaa"))
87
70
dc.open_workingtree().commit('msg')
89
output, error = self.run_bzr("dpush -d dc d")
90
self.assertEquals(error, "Pushed up to revision 2.\n")
91
self.check_output("", "status dc")
72
script.run_script(self, """
74
2>Pushed up to revision 2.
93
78
def test_dpush_new(self):
94
79
b = self.make_dummy_builder('d').get_branch()
99
84
dc_tree.add("foofile")
100
85
dc_tree.commit("msg")
102
self.check_output("", "dpush -d dc d")
103
self.check_output("2\n", "revno dc")
104
self.check_output("", "status dc")
87
script.run_script(self, '''
89
2>Pushed up to revision 2.
106
95
def test_dpush_wt_diff(self):
107
96
b = self.make_dummy_builder('d').get_branch()
113
102
newrevid = dc_tree.commit('msg')
115
104
self.build_tree_contents([("dc/foofile", "blaaaal")])
116
self.check_output("", "dpush -d dc d --no-strict")
105
script.run_script(self, '''
106
$ bzr dpush -d dc d --no-strict
107
2>Pushed up to revision 2.
117
109
self.assertFileEqual("blaaaal", "dc/foofile")
118
110
# if the dummy vcs wasn't that dummy we could uncomment the line below
119
111
# self.assertFileEqual("blaaaa", "d/foofile")
120
self.check_output('modified:\n foofile\n', "status dc")
112
script.run_script(self, '''
122
118
def test_diverged(self):
123
119
builder = self.make_dummy_builder('d')
166
162
class TestDpushStrictWithChanges(TestDpushStrictMixin,
167
163
test_push.TestPushStrictWithChanges):
165
scenarios = test_push.strict_push_change_scenarios
169
167
_changes_type = None # Set by load_tests