28
28
from bzrlib.bundle import serializer
29
29
from bzrlib.transport import memory
32
def load_tests(standard_tests, module, loader):
33
"""Multiply tests for the send command."""
34
result = loader.suiteClass()
36
# one for each king of change
37
changes_tests, remaining_tests = tests.split_suite_by_condition(
38
standard_tests, tests.condition_isinstance((
39
TestSendStrictWithChanges,
43
dict(_changes_type='_uncommitted_changes')),
45
dict(_changes_type='_pending_merges')),
47
dict(_changes_type='_out_of_sync_trees')),
49
tests.multiply_tests(changes_tests, changes_scenarios, result)
50
# No parametrization for the remaining tests
51
result.addTests(remaining_tests)
30
from bzrlib.tests import (
36
load_tests = scenarios.load_tests_apply_scenarios
56
39
class TestSendMixin(object):
207
190
def test_note_revisions(self):
208
191
stderr = self.run_send([])[1]
209
self.assertEndsWith(stderr, '\nBundling 1 revision(s).\n')
192
self.assertEndsWith(stderr, '\nBundling 1 revision.\n')
211
194
def test_mailto_option(self):
212
195
b = branch.Branch.open('branch')
307
290
_default_sent_revs = ['local']
308
291
_default_errors = ['Working tree ".*/local/" has uncommitted '
309
292
'changes \(See bzr status\)\.',]
293
_default_additional_error = 'Use --no-strict to force the send.\n'
294
_default_additional_warning = 'Uncommitted changes will not be sent.'
311
296
def set_config_send_strict(self, value):
312
297
# set config var (any of bazaar.conf, locations.conf, branch.conf
314
conf = self.local_tree.branch.get_config()
315
conf.set_user_option('send_strict', value)
299
conf = self.local_tree.branch.get_config_stack()
300
conf.set('send_strict', value)
317
302
def assertSendFails(self, args):
318
self.run_send(args, rc=3, err_re=self._default_errors)
303
out, err = self.run_send(args, rc=3, err_re=self._default_errors)
304
self.assertContainsRe(err, self._default_additional_error)
320
def assertSendSucceeds(self, args, revs=None):
306
def assertSendSucceeds(self, args, revs=None, with_warning=False):
308
err_re = self._default_errors
322
312
revs = self._default_sent_revs
323
out, err = self.run_send(args)
325
'Bundling %d revision(s).\n' % len(revs), err)
313
out, err = self.run_send(args, err_re=err_re)
315
bundling_revs = 'Bundling %d revision.\n'% len(revs)
317
bundling_revs = 'Bundling %d revisions.\n' % len(revs)
319
self.assertContainsRe(err, self._default_additional_warning)
320
self.assertEndsWith(err, bundling_revs)
322
self.assertEquals(bundling_revs, err)
326
323
md = merge_directive.MergeDirective.from_lines(StringIO(out))
327
324
self.assertEqual('parent', md.base_revision_id)
328
325
br = serializer.read_bundle(StringIO(md.get_raw_bundle()))
357
354
class TestSendStrictWithChanges(tests.TestCaseWithTransport,
358
TestSendStrictMixin):
355
TestSendStrictMixin):
357
# These are textually the same as test_push.strict_push_change_scenarios,
358
# but since the functions are reimplemented here, the definitions are left
362
dict(_changes_type='_uncommitted_changes')),
364
dict(_changes_type='_pending_merges')),
365
('out-of-sync-trees',
366
dict(_changes_type='_out_of_sync_trees')),
360
369
_changes_type = None # Set by load_tests
396
405
self._default_sent_revs = ['modified-in-local', 'local']
398
407
def test_send_default(self):
399
self.assertSendFails([])
408
self.assertSendSucceeds([], with_warning=True)
401
410
def test_send_with_revision(self):
402
411
self.assertSendSucceeds(['-r', 'revid:local'], revs=['local'])
412
421
self.assertSendFails([])
413
422
self.assertSendSucceeds(['--no-strict'])
416
424
def test_send_bogus_config_var_ignored(self):
417
425
self.set_config_send_strict("I'm unsure")
418
self.assertSendFails([])
426
self.assertSendSucceeds([], with_warning=True)
421
428
def test_send_no_strict_command_line_override_config(self):
422
429
self.set_config_send_strict('true')