annotate tests/test-config.py @ 21:ffef7df076e8

client: rewrite config()
author Idan Kamara <idankk86@gmail.com>
date Thu, 11 Aug 2011 16:02:01 +0300
parents
children e738d6fe5f3f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
21
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
1 import os, common, hglib
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
2
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
3 class test_config(common.basetest):
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
4 def setUp(self):
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
5 common.basetest.setUp(self)
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
6 open('.hg/hgrc', 'a').write('[section]\nkey=value\n')
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
7 self.client = hglib.open()
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
8
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
9 def test_basic(self):
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
10 config = self.client.config()
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
11
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
12 self.assertTrue(('section', 'key', 'value') in self.client.config())
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
13
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
14 self.assertTrue([('section', 'key', 'value')],
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
15 self.client.config('section'))
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
16 self.assertTrue([('section', 'key', 'value')],
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
17 self.client.config(['section', 'foo']))
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
18 self.assertRaises(hglib.error.CommandError,
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
19 self.client.config, ['a.b', 'foo'])
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
20
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
21 def test_show_source(self):
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
22 config = self.client.config(showsource=True)
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
23
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
24 self.assertTrue((os.path.abspath('.hg/hgrc') + ':2',
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
25 'section', 'key', 'value') in config)