~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_dpush.py

  • Committer: Robert Collins
  • Date: 2010-05-06 07:48:22 UTC
  • mto: This revision was merged to the branch mainline in revision 5223.
  • Revision ID: robertc@robertcollins.net-20100506074822-0bsgf2j4h8jx0xkk
Added ``bzrlib.tests.matchers`` as a place to put matchers, along with
our first in-tree matcher. See the module docstring for details.
(Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2009, 2010, 2011 Canonical Ltd
 
1
# Copyright (C) 2009, 2010 Canonical Ltd
2
2
#
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
29
29
    )
30
30
from bzrlib.tests import (
31
31
    blackbox,
32
 
    script,
33
32
    test_foreign,
34
33
    )
35
34
from bzrlib.tests.blackbox import test_push
36
 
from bzrlib.tests.scenarios import (
37
 
    load_tests_apply_scenarios,
38
 
    )
39
 
 
40
 
 
41
 
load_tests = load_tests_apply_scenarios
42
 
 
43
 
 
44
 
class TestDpush(tests.TestCaseWithTransport):
 
35
 
 
36
 
 
37
def load_tests(standard_tests, module, loader):
 
38
    """Multiply tests for the dpush command."""
 
39
    result = loader.suiteClass()
 
40
 
 
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,
 
45
                )))
 
46
    changes_scenarios = [
 
47
        ('uncommitted',
 
48
         dict(_changes_type= '_uncommitted_changes')),
 
49
        ('pending-merges',
 
50
         dict(_changes_type= '_pending_merges')),
 
51
        ('out-of-sync-trees',
 
52
         dict(_changes_type= '_out_of_sync_trees')),
 
53
        ]
 
54
    tests.multiply_tests(changes_tests, changes_scenarios, result)
 
55
    # No parametrization for the remaining tests
 
56
    result.addTests(remaining_tests)
 
57
 
 
58
    return result
 
59
 
 
60
 
 
61
class TestDpush(blackbox.ExternalBase):
45
62
 
46
63
    def setUp(self):
47
64
        super(TestDpush, self).setUp()
69
86
        self.build_tree(("dc/foo", "blaaaa"))
70
87
        dc.open_workingtree().commit('msg')
71
88
 
72
 
        script.run_script(self, """
73
 
            $ bzr dpush -d dc d
74
 
            2>Pushed up to revision 2.
75
 
            $ bzr status dc
76
 
            """)
 
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")
77
92
 
78
93
    def test_dpush_new(self):
79
94
        b = self.make_dummy_builder('d').get_branch()
84
99
        dc_tree.add("foofile")
85
100
        dc_tree.commit("msg")
86
101
 
87
 
        script.run_script(self, '''
88
 
            $ bzr dpush -d dc d
89
 
            2>Pushed up to revision 2.
90
 
            $ bzr revno dc
91
 
            2
92
 
            $ bzr status dc
93
 
            ''')
 
102
        self.check_output("", "dpush -d dc d")
 
103
        self.check_output("2\n", "revno dc")
 
104
        self.check_output("", "status dc")
94
105
 
95
106
    def test_dpush_wt_diff(self):
96
107
        b = self.make_dummy_builder('d').get_branch()
102
113
        newrevid = dc_tree.commit('msg')
103
114
 
104
115
        self.build_tree_contents([("dc/foofile", "blaaaal")])
105
 
        script.run_script(self, '''
106
 
            $ bzr dpush -d dc d --no-strict
107
 
            2>Pushed up to revision 2.
108
 
            ''')
 
116
        self.check_output("", "dpush -d dc d --no-strict")
109
117
        self.assertFileEqual("blaaaal", "dc/foofile")
110
118
        # if the dummy vcs wasn't that dummy we could uncomment the line below
111
119
        # self.assertFileEqual("blaaaa", "d/foofile")
112
 
        script.run_script(self, '''
113
 
            $ bzr status dc
114
 
            modified:
115
 
              foofile
116
 
            ''')
 
120
        self.check_output('modified:\n  foofile\n', "status dc")
117
121
 
118
122
    def test_diverged(self):
119
123
        builder = self.make_dummy_builder('d')
162
166
class TestDpushStrictWithChanges(TestDpushStrictMixin,
163
167
                                 test_push.TestPushStrictWithChanges):
164
168
 
165
 
    scenarios = test_push.strict_push_change_scenarios
166
 
 
167
169
    _changes_type = None # Set by load_tests
168
170
 
169
171
    def setUp(self):
172
174
 
173
175
    def test_push_with_revision(self):
174
176
        raise tests.TestNotApplicable('dpush does not handle --revision')
 
177