~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_config.py

  • Committer: Martin Pool
  • Date: 2006-03-06 11:20:10 UTC
  • mfrom: (1593 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1611.
  • Revision ID: mbp@sourcefrog.net-20060306112010-17c0170dde5d1eea
[merge] large merge to sync with bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
from bzrlib.tests import TestCase, TestCaseInTempDir
29
29
 
30
30
 
 
31
sample_long_alias="log -r-15..-1 --line"
31
32
sample_config_text = ("[DEFAULT]\n"
32
33
                      "email=Robert Collins <robertc@example.com>\n"
33
34
                      "editor=vim\n"
34
35
                      "gpg_signing_command=gnome-gpg\n"
35
 
                      "user_global_option=something\n")
 
36
                      "log_format=short\n"
 
37
                      "user_global_option=something\n"
 
38
                      "[ALIASES]\n"
 
39
                      "h=help\n"
 
40
                      "ll=" + sample_long_alias + "\n")
36
41
 
37
42
 
38
43
sample_always_signatures = ("[DEFAULT]\n"
70
75
                        "#testing explicit beats globs\n")
71
76
 
72
77
 
 
78
 
73
79
class InstrumentedConfigObj(object):
74
80
    """A config obj look-enough-alike to record calls made to it."""
75
81
 
128
134
        return self._signatures
129
135
 
130
136
 
 
137
bool_config = """[DEFAULT]
 
138
active = true
 
139
inactive = false
 
140
[UPPERCASE]
 
141
active = True
 
142
nonactive = False
 
143
"""
 
144
class TestConfigObj(TestCase):
 
145
    def test_get_bool(self):
 
146
        from bzrlib.config import ConfigObj
 
147
        co = ConfigObj(StringIO(bool_config))
 
148
        self.assertIs(co.get_bool('DEFAULT', 'active'), True)
 
149
        self.assertIs(co.get_bool('DEFAULT', 'inactive'), False)
 
150
        self.assertIs(co.get_bool('UPPERCASE', 'active'), True)
 
151
        self.assertIs(co.get_bool('UPPERCASE', 'nonactive'), False)
 
152
 
 
153
 
131
154
class TestConfig(TestCase):
132
155
 
133
156
    def test_constructs(self):
176
199
        my_config = config.Config()
177
200
        self.assertEqual(None, my_config.post_commit())
178
201
 
 
202
    def test_log_format_default(self):
 
203
        my_config = config.Config()
 
204
        self.assertEqual('long', my_config.log_format())
 
205
 
179
206
 
180
207
class TestConfigPath(TestCase):
181
208
 
352
379
        my_config = self._get_sample_config()
353
380
        self.assertEqual(None, my_config.post_commit())
354
381
 
 
382
    def test_configured_logformat(self):
 
383
        my_config = self._get_sample_config()
 
384
        self.assertEqual("short", my_config.log_format())
 
385
 
 
386
    def test_get_alias(self):
 
387
        my_config = self._get_sample_config()
 
388
        self.assertEqual('help', my_config.get_alias('h'))
 
389
 
 
390
    def test_get_no_alias(self):
 
391
        my_config = self._get_sample_config()
 
392
        self.assertEqual(None, my_config.get_alias('foo'))
 
393
 
 
394
    def test_get_long_alias(self):
 
395
        my_config = self._get_sample_config()
 
396
        self.assertEqual(sample_long_alias, my_config.get_alias('ll'))
355
397
 
356
398
class TestLocationConfig(TestCase):
357
399