models: Remove unused module
[git-cola.git] / test / test_cola_gitcfg.py
blobeef8160201c13f2ce047f16bb338f5980daf1c3c
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)
40 def test_bool_no_value(self):
41 self.shell('printf "[test]\n" >> .git/config')
42 self.shell('printf "\tbool\n" >> .git/config')
43 self.assertEqual(self.config.get('test.bool'), True)
45 def test_empty_value(self):
46 self.shell('printf "[test]\n" >> .git/config')
47 self.shell('printf "\tvalue = \n" >> .git/config')
48 self.assertEqual(self.config.get('test.value'), '')
50 def test_default(self):
51 """Test default values in get()."""
52 self.assertEqual(self.config.get('does.not.exist'), None)
53 self.assertEqual(self.config.get('does.not.exist', default=42), 42)
56 if __name__ == '__main__':
57 unittest.main()