gitcfg: Support 'yes' and 'no' as valid booleans
[git-cola.git] / test / test_cola_gitcfg.py
blobd94edb829889028e1f43869eb678b0a0dc6d699d
1 import unittest
3 import helper
4 from cola import gitcfg
7 class GitConfigTestCase(helper.GitRepositoryTestCase):
8 """Tests the cola.gitcmds module."""
9 def setUp(self):
10 helper.GitRepositoryTestCase.setUp(self)
11 self.config = gitcfg.instance()
13 def test_string(self):
14 """Test string values in get()."""
15 self.shell('git config test.value test')
16 self.assertEqual(self.config.get('test.value'), 'test')
18 def test_int(self):
19 """Test int values in get()."""
20 self.shell('git config test.int 42')
21 self.assertEqual(self.config.get('test.int'), 42)
23 def test_true(self):
24 """Test bool values in get()."""
25 self.shell('git config test.bool true')
26 self.assertEqual(self.config.get('test.bool'), True)
28 def test_false(self):
29 self.shell('git config test.bool false')
30 self.assertEqual(self.config.get('test.bool'), False)
32 def test_yes(self):
33 self.shell('git config test.bool yes')
34 self.assertEqual(self.config.get('test.bool'), True)
36 def test_no(self):
37 self.shell('git config test.bool false')
38 self.assertEqual(self.config.get('test.bool'), False)
41 def test_default(self):
42 """Test default values in get()."""
43 self.assertEqual(self.config.get('does.not.exist'), None)
44 self.assertEqual(self.config.get('does.not.exist', default=42), 42)
47 if __name__ == '__main__':
48 unittest.main()