/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_annotate_config.py

  • Committer: Vincent Ladeuil
  • Date: 2009-05-28 15:14:14 UTC
  • mto: This revision was merged to the branch mainline in revision 640.
  • Revision ID: v.ladeuil+lp@free.fr-20090528151414-q5rlh8kaicx2hgqo
Implement commit message saving without modifying bzrlib.

* tests/test_commit.py:
(TestSavedCommitMessages.setUp): Install the post_uncommit hook
for all relevant tests.
(TestUncommitHook.setUp): Use explicit rev-ids to ease debugging.

* commit.py: 
Fix imports. Integrate SavedCommitMessagesManager so that we don't
need to modify bzrlib anymore.
(CommitDialog.__init__, CommitDialog._fill_in_files,
CommitDialog._construct_global_message, CommitDialog._do_cancel,
CommitDialog._do_commit): Stop testing can_save_commit_messages,
SavedCommitMessagesManager is always available now.
(SavedCommitMessagesManager): Borrowed from Anne Mohsen's patch.
(save_commit_messages): Implement the post_uncommit hook.

* __init__.py:
Install a lazy hook.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Test the annotate configuration functionality."""
18
18
 
19
 
import os
20
 
 
21
19
from bzrlib import (
22
20
    tests,
23
21
    )
26
24
    config,
27
25
    gannotate,
28
26
    )
29
 
from bzrlib.plugins.gtk.annotate.config import gannotate_config_filename
30
 
 
31
27
 
32
28
class TestConfig(tests.TestCaseInTempDir):
33
29
 
34
30
    def setUp(self):
35
 
        # Create an instance before the env is changed so that
36
 
        # icon lookups work.
 
31
        super(TestConfig, self).setUp()
37
32
        self.window = gannotate.GAnnotateWindow()
38
 
        super(TestConfig, self).setUp()
39
 
 
40
 
    def tearDown(self):
41
 
        self.window.destroy()
42
 
        super(TestConfig, self).tearDown()
43
33
 
44
34
    def test_create_initial_config(self):
45
35
        """We can create a config even without a prior conf file"""
48
38
        width = conf['window']['width']
49
39
        # configobj presents attributes as strings only
50
40
        self.assertIsInstance(width, str)
51
 
 
52
 
    def test_write(self):
53
 
        """The window state and pane position is saved."""
54
 
        conf = config.GAnnotateConfig(self.window)
55
 
        self.window.pane.set_position(200)
56
 
        self.assertIs(False, conf._write())
57
 
        self.assertEqual(200, conf['window']['pane_position'])
58
 
        config_path = gannotate_config_filename()
59
 
        self.assertIs(True, os.path.isfile(config_path))
60
 
        with open(config_path) as config_file:
61
 
            config_data = config_file.read()
62
 
        self.assertIn('pane_position = 200', config_data)