~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: John Arbash Meinel
  • Date: 2010-02-04 16:06:36 UTC
  • mfrom: (5007 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5023.
  • Revision ID: john@arbash-meinel.com-20100204160636-xqeuwz8bwt8bbts4
Merge bzr.dev 5007, resolve conflict, update NEWS

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2011 Canonical Ltd
 
1
# Copyright (C) 2006, 2007, 2008, 2009 Canonical Ltd
2
2
# Authors: Aaron Bentley
3
3
#
4
4
# This program is free software; you can redistribute it and/or modify
26
26
    tests,
27
27
    )
28
28
from bzrlib.bundle import serializer
29
 
from bzrlib.transport import memory
30
 
from bzrlib.tests import (
31
 
    scenarios,
32
 
    script,
33
 
    )
34
 
 
35
 
 
36
 
load_tests = scenarios.load_tests_apply_scenarios
 
29
 
 
30
 
 
31
def load_tests(standard_tests, module, loader):
 
32
    """Multiply tests for the send command."""
 
33
    result = loader.suiteClass()
 
34
 
 
35
    # one for each king of change
 
36
    changes_tests, remaining_tests = tests.split_suite_by_condition(
 
37
        standard_tests, tests.condition_isinstance((
 
38
                TestSendStrictWithChanges,
 
39
                )))
 
40
    changes_scenarios = [
 
41
        ('uncommitted',
 
42
         dict(_changes_type='_uncommitted_changes')),
 
43
        ('pending_merges',
 
44
         dict(_changes_type='_pending_merges')),
 
45
        ('out-of-sync-trees',
 
46
         dict(_changes_type='_out_of_sync_trees')),
 
47
        ]
 
48
    tests.multiply_tests(changes_tests, changes_scenarios, result)
 
49
    # No parametrization for the remaining tests
 
50
    result.addTests(remaining_tests)
 
51
 
 
52
    return result
37
53
 
38
54
 
39
55
class TestSendMixin(object):
264
280
        self.assertEqual('rev3', md.revision_id)
265
281
 
266
282
    def test_nonexistant_branch(self):
267
 
        self.vfs_transport_factory = memory.MemoryServer
 
283
        self.vfs_transport_factory = tests.MemoryServer
268
284
        location = self.get_url('absentdir/')
269
285
        out, err = self.run_bzr(["send", "--from", location], retcode=3)
270
286
        self.assertEqual(out, '')
290
306
    _default_sent_revs = ['local']
291
307
    _default_errors = ['Working tree ".*/local/" has uncommitted '
292
308
                       '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.'
295
309
 
296
310
    def set_config_send_strict(self, value):
297
311
        # set config var (any of bazaar.conf, locations.conf, branch.conf
300
314
        conf.set_user_option('send_strict', value)
301
315
 
302
316
    def assertSendFails(self, args):
303
 
        out, err = self.run_send(args, rc=3, err_re=self._default_errors)
304
 
        self.assertContainsRe(err, self._default_additional_error)
 
317
        self.run_send(args, rc=3, err_re=self._default_errors)
305
318
 
306
 
    def assertSendSucceeds(self, args, revs=None, with_warning=False):
307
 
        if with_warning:
308
 
            err_re = self._default_errors
309
 
        else:
310
 
            err_re = []
 
319
    def assertSendSucceeds(self, args, revs=None):
311
320
        if revs is None:
312
321
            revs = self._default_sent_revs
313
 
        out, err = self.run_send(args, err_re=err_re)
314
 
        bundling_revs = 'Bundling %d revision(s).\n' % len(revs)
315
 
        if with_warning:
316
 
            self.assertContainsRe(err, self._default_additional_warning)
317
 
            self.assertEndsWith(err, bundling_revs)
318
 
        else:
319
 
            self.assertEquals(bundling_revs, err)
 
322
        out, err = self.run_send(args)
 
323
        self.assertEquals(
 
324
            'Bundling %d revision(s).\n' % len(revs), err)
320
325
        md = merge_directive.MergeDirective.from_lines(StringIO(out))
321
326
        self.assertEqual('parent', md.base_revision_id)
322
327
        br = serializer.read_bundle(StringIO(md.get_raw_bundle()))
349
354
 
350
355
 
351
356
class TestSendStrictWithChanges(tests.TestCaseWithTransport,
352
 
                                TestSendStrictMixin):
353
 
 
354
 
    # These are textually the same as test_push.strict_push_change_scenarios,
355
 
    # but since the functions are reimplemented here, the definitions are left
356
 
    # here too.
357
 
    scenarios = [
358
 
        ('uncommitted',
359
 
         dict(_changes_type='_uncommitted_changes')),
360
 
        ('pending_merges',
361
 
         dict(_changes_type='_pending_merges')),
362
 
        ('out-of-sync-trees',
363
 
         dict(_changes_type='_out_of_sync_trees')),
364
 
        ]
 
357
                                   TestSendStrictMixin):
365
358
 
366
359
    _changes_type = None # Set by load_tests
367
360
 
402
395
        self._default_sent_revs = ['modified-in-local', 'local']
403
396
 
404
397
    def test_send_default(self):
405
 
        self.assertSendSucceeds([], with_warning=True)
 
398
        self.assertSendFails([])
406
399
 
407
400
    def test_send_with_revision(self):
408
401
        self.assertSendSucceeds(['-r', 'revid:local'], revs=['local'])
418
411
        self.assertSendFails([])
419
412
        self.assertSendSucceeds(['--no-strict'])
420
413
 
 
414
 
421
415
    def test_send_bogus_config_var_ignored(self):
422
416
        self.set_config_send_strict("I'm unsure")
423
 
        self.assertSendSucceeds([], with_warning=True)
 
417
        self.assertSendFails([])
 
418
 
424
419
 
425
420
    def test_send_no_strict_command_line_override_config(self):
426
421
        self.set_config_send_strict('true')