/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: John Arbash Meinel
  • Date: 2007-10-02 17:34:18 UTC
  • mto: (322.1.1 trunk) (330.3.3 trunk)
  • mto: This revision was merged to the branch mainline in revision 368.
  • Revision ID: john@arbash-meinel.com-20071002173418-m7sabp62wnth76k3
Beginning to support actual commit.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
import os
20
20
 
 
21
import gtk
 
22
 
21
23
from bzrlib import (
22
24
    tests,
23
25
    revision,
536
538
                          ('a-id', 'a', True),
537
539
                          ('b-id', 'b', True),
538
540
                         ], [(r[0], r[1], r[2]) for r in dlg._files_store])
 
541
 
 
542
 
 
543
class TestCommitDialog_Commit(tests.TestCaseWithTransport):
 
544
    """Tests on the actual 'commit' button being pushed."""
 
545
 
 
546
    def test_commit_no_message(self):
 
547
        tree = self.make_branch_and_tree('tree')
 
548
        self.build_tree(['tree/a', 'tree/b'])
 
549
        tree.add(['a'], ['a-id'])
 
550
        rev_id = tree.commit('one')
 
551
 
 
552
        tree.add(['b'], ['b-id'])
 
553
 
 
554
        dlg = commit.CommitDialog(tree)
 
555
        questions = []
 
556
        def _question_cancel(*args):
 
557
            questions.append(args)
 
558
            questions.append('NO')
 
559
            return gtk.RESPONSE_NO
 
560
 
 
561
        def _question_ok(*args):
 
562
            questions.append(args)
 
563
            questions.append('OK')
 
564
            return gtk.RESPONSE_OK
 
565
 
 
566
        dlg._question_dialog = _question_cancel
 
567
        dlg._do_commit()
 
568
        self.assertEqual(
 
569
            [('Commit with an empty message?',
 
570
              'You can describe your commit intent in the message.'),
 
571
              'NO',
 
572
            ], questions)
 
573
        # By saying NO, nothing should be committed.
 
574
        self.assertEqual(rev_id, tree.last_revision())
 
575
        self.assertIs(None, dlg.committed_revision_id)
 
576
 
 
577
        dlg._question_dialog = _question_ok
 
578
        del questions[:]
 
579
 
 
580
        dlg._do_commit()
 
581
        self.assertEqual(
 
582
            [('Commit with an empty message?',
 
583
              'You can describe your commit intent in the message.'),
 
584
              'OK',
 
585
            ], questions)
 
586
        committed = tree.last_revision()
 
587
        self.assertNotEqual(rev_id, committed)
 
588
        self.assertEqual(committed, dlg.committed_revision_id)
 
589
 
 
590
    def test_initial_commit(self):
 
591
        tree = self.make_branch_and_tree('tree')
 
592
        self.build_tree(['tree/a'])
 
593
        tree.add(['a'], ['a-id'])
 
594
 
 
595
        dlg = commit.CommitDialog(tree)
 
596
        dlg._global_message_text_view.get_buffer().set_text('Some text\n')
 
597
        dlg._do_commit()
 
598
 
 
599
        last_rev = tree.last_revision()
 
600
        self.assertEqual(last_rev, dlg.committed_revision_id)
 
601
        rev = tree.branch.repository.get_revision(last_rev)
 
602
        self.assertEqual(last_rev, rev.revision_id)
 
603
        self.assertEqual('Some text\n', rev.message)