/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz

« back to all changes in this revision

Viewing changes to tests/test_commit.py

  • Committer: Jelmer Vernooij
  • Date: 2008-06-29 18:12:29 UTC
  • mto: This revision was merged to the branch mainline in revision 519.
  • Revision ID: jelmer@samba.org-20080629181229-1l2m4cf7vvbyh8qg
Simplify progress bar code, use embedded progress bar inside viz window.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007, 2008 John Arbash Meinel <john@arbash-meinel.com>
 
1
# Copyright (C) 2007 John Arbash Meinel <john@arbash-meinel.com>
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
644
644
                            'message':'message\nfor b_dir\n'},
645
645
                          ]), dlg._get_specific_files())
646
646
 
647
 
    def test_specific_files_sanitizes_messages(self):
648
 
        tree = self.make_branch_and_tree('tree')
649
 
        tree.branch.get_config().set_user_option('per_file_commits', 'true')
650
 
        self.build_tree(['tree/a_file', 'tree/b_dir/'])
651
 
        tree.add(['a_file', 'b_dir'], ['1a-id', '0b-id'])
652
 
 
653
 
        dlg = commit.CommitDialog(tree)
654
 
        dlg._commit_selected_radio.set_active(True)
655
 
        self.assertEqual((['a_file', 'b_dir'], []), dlg._get_specific_files())
656
 
 
657
 
        dlg._treeview_files.set_cursor((1,))
658
 
        dlg._set_file_commit_message('Test\r\nmessage\rfor a_file\n')
659
 
        dlg._treeview_files.set_cursor((2,))
660
 
        dlg._set_file_commit_message('message\r\nfor\nb_dir\r')
661
 
 
662
 
        self.assertEqual((['a_file', 'b_dir'],
663
 
                          [{'path':'a_file', 'file_id':'1a-id',
664
 
                            'message':'Test\nmessage\nfor a_file\n'},
665
 
                           {'path':'b_dir', 'file_id':'0b-id',
666
 
                            'message':'message\nfor\nb_dir\n'},
667
 
                          ]), dlg._get_specific_files())
668
 
 
669
647
 
670
648
class TestCommitDialog_Commit(tests.TestCaseWithTransport):
671
649
    """Tests on the actual 'commit' button being pushed."""
673
651
    def _set_question_yes(self, dlg):
674
652
        """Set the dialog to answer YES to any questions."""
675
653
        self.questions = []
676
 
        def _question_yes(*args, **kwargs):
 
654
        def _question_yes(*args):
677
655
            self.questions.append(args)
678
656
            self.questions.append('YES')
679
657
            return gtk.RESPONSE_YES
682
660
    def _set_question_no(self, dlg):
683
661
        """Set the dialog to answer NO to any questions."""
684
662
        self.questions = []
685
 
        def _question_no(*args, **kwargs):
 
663
        def _question_no(*args):
686
664
            self.questions.append(args)
687
665
            self.questions.append('NO')
688
666
            return gtk.RESPONSE_NO
709
687
        self.assertEqual(last_rev, dlg.committed_revision_id)
710
688
        self.assertEqual(rev_id1, tree.branch.last_revision())
711
689
 
712
 
    def test_commit_global_sanitizes_message(self):
713
 
        tree = self.make_branch_and_tree('tree')
714
 
        self.build_tree(['tree/a'])
715
 
        tree.add(['a'], ['a-id'])
716
 
        rev_id1 = tree.commit('one')
717
 
 
718
 
        self.build_tree(['tree/b'])
719
 
        tree.add(['b'], ['b-id'])
720
 
        dlg = commit.CommitDialog(tree)
721
 
        # With the check box set, it should only effect the local branch
722
 
        dlg._set_global_commit_message('Commit\r\nmessage\rfoo\n')
723
 
        dlg._do_commit()
724
 
        rev = tree.branch.repository.get_revision(tree.last_revision())
725
 
        self.assertEqual('Commit\nmessage\nfoo\n', rev.message)
726
 
 
727
690
    def test_bound_commit_both(self):
728
691
        tree = self.make_branch_and_tree('tree')
729
692
        self.build_tree(['tree/a'])
745
708
        self.assertEqual(last_rev, dlg.committed_revision_id)
746
709
        self.assertEqual(last_rev, tree.branch.last_revision())
747
710
 
748
 
    def test_commit_empty_message(self):
 
711
    def test_commit_no_message(self):
749
712
        tree = self.make_branch_and_tree('tree')
750
713
        self.build_tree(['tree/a', 'tree/b'])
751
714
        tree.add(['a'], ['a-id'])
1067
1030
                          {'path':u'\u03a9', 'file_id':'omega-id',
1068
1031
                           'message':u'\u03a9 is the end of all things.\n'},
1069
1032
                         ], file_info_decoded)
1070
 
 
1071
 
 
1072
 
class TestSanitizeMessage(tests.TestCase):
1073
 
 
1074
 
    def assertSanitize(self, expected, original):
1075
 
        self.assertEqual(expected,
1076
 
                         commit._sanitize_and_decode_message(original))
1077
 
 
1078
 
    def test_untouched(self):
1079
 
        self.assertSanitize('foo\nbar\nbaz\n', 'foo\nbar\nbaz\n')
1080
 
 
1081
 
    def test_converts_cr_to_lf(self):
1082
 
        self.assertSanitize('foo\nbar\nbaz\n', 'foo\rbar\rbaz\r')
1083
 
 
1084
 
    def test_converts_crlf_to_lf(self):
1085
 
        self.assertSanitize('foo\nbar\nbaz\n', 'foo\r\nbar\r\nbaz\r\n')
1086
 
 
1087
 
    def test_converts_mixed_to_lf(self):
1088
 
        self.assertSanitize('foo\nbar\nbaz\n', 'foo\r\nbar\rbaz\n')