/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

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

  • Committer: Vincent Ladeuil
  • Date: 2010-01-25 15:55:48 UTC
  • mto: (4985.1.4 add-attr-cleanup)
  • mto: This revision was merged to the branch mainline in revision 4988.
  • Revision ID: v.ladeuil+lp@free.fr-20100125155548-0l352pujvt5bzl5e
Deploy addAttrCleanup on the whole test suite.

Several use case worth mentioning:

- setting a module or any other object attribute is the majority
by far. In some cases the setting itself is deferred but most of
the time we want to set at the same time we add the cleanup.

- there multiple occurrences of protecting hooks or ui factory
which are now useless (the test framework takes care of that now),

- there was some lambda uses that can now be avoided.

That first cleanup already simplifies things a lot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2010 Canonical Ltd
 
1
# Copyright (C) 2005, 2007, 2008 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
35
35
    blackbox,
36
36
    http_server,
37
37
    test_foreign,
38
 
    test_server,
39
38
    )
40
39
from bzrlib.transport import memory
41
40
 
661
660
    _default_wd = 'local'
662
661
    _default_errors = ['Working tree ".*/local/" has uncommitted '
663
662
                       'changes \(See bzr status\)\.',]
664
 
    _default_additional_error = 'Use --no-strict to force the push.\n'
665
 
    _default_additional_warning = 'Uncommitted changes will not be pushed.'
666
 
 
 
663
    _default_pushed_revid = 'modified'
667
664
 
668
665
    def assertPushFails(self, args):
669
 
        out, err = self.run_bzr_error(self._default_errors,
670
 
                                      self._default_command + args,
671
 
                                      working_dir=self._default_wd, retcode=3)
672
 
        self.assertContainsRe(err, self._default_additional_error)
 
666
        self.run_bzr_error(self._default_errors, self._default_command + args,
 
667
                           working_dir=self._default_wd, retcode=3)
673
668
 
674
 
    def assertPushSucceeds(self, args, with_warning=False, revid_to_push=None):
675
 
        if with_warning:
676
 
            error_regexes = self._default_errors
677
 
        else:
678
 
            error_regexes = []
679
 
        out, err = self.run_bzr(self._default_command + args,
680
 
                                working_dir=self._default_wd,
681
 
                                error_regexes=error_regexes)
682
 
        if with_warning:
683
 
            self.assertContainsRe(err, self._default_additional_warning)
684
 
        else:
685
 
            self.assertNotContainsRe(err, self._default_additional_warning)
686
 
        branch_from = branch.Branch.open(self._default_wd)
687
 
        if revid_to_push is None:
688
 
            revid_to_push = branch_from.last_revision()
689
 
        branch_to = branch.Branch.open('to')
690
 
        repo_to = branch_to.repository
691
 
        self.assertTrue(repo_to.has_revision(revid_to_push))
692
 
        self.assertEqual(revid_to_push, branch_to.last_revision())
 
669
    def assertPushSucceeds(self, args, pushed_revid=None):
 
670
        self.run_bzr(self._default_command + args,
 
671
                     working_dir=self._default_wd)
 
672
        if pushed_revid is None:
 
673
            pushed_revid = self._default_pushed_revid
 
674
        tree_to = workingtree.WorkingTree.open('to')
 
675
        repo_to = tree_to.branch.repository
 
676
        self.assertTrue(repo_to.has_revision(pushed_revid))
 
677
        self.assertEqual(tree_to.branch.last_revision_info()[1], pushed_revid)
693
678
 
694
679
 
695
680
 
756
741
        self._default_wd = 'checkout'
757
742
        self._default_errors = ["Working tree is out of date, please run"
758
743
                                " 'bzr update'\.",]
 
744
        self._default_pushed_revid = 'modified-in-local'
759
745
 
760
746
    def test_push_default(self):
761
 
        self.assertPushSucceeds([], with_warning=True)
 
747
        self.assertPushFails([])
762
748
 
763
749
    def test_push_with_revision(self):
764
 
        self.assertPushSucceeds(['-r', 'revid:added'], revid_to_push='added')
 
750
        self.assertPushSucceeds(['-r', 'revid:added'], pushed_revid='added')
765
751
 
766
752
    def test_push_no_strict(self):
767
753
        self.assertPushSucceeds(['--no-strict'])
775
761
 
776
762
    def test_push_bogus_config_var_ignored(self):
777
763
        self.set_config_push_strict("I don't want you to be strict")
778
 
        self.assertPushSucceeds([], with_warning=True)
 
764
        self.assertPushFails([])
779
765
 
780
766
    def test_push_no_strict_command_line_override_config(self):
781
767
        self.set_config_push_strict('yES')