commands: Don't expandvars() the command since 'sh -c' doess it for us
[git-cola.git] / test / test_cola_git_ops.py
blob0cb22d3b25e7f62017713a802a0eb36edc4cbc9d
1 #!/usr/bin/env python
2 """Tests basic git operations: commit, log, config"""
3 import os
4 import unittest
6 import helper
7 from cola.models import main
9 class ColaBasicGitTestCase(helper.GitRepositoryTestCase):
11 def setUp(self):
12 helper.GitRepositoryTestCase.setUp(self, commit=False)
14 def test_git_commit(self):
15 """Test running 'git commit' via cola.git"""
16 self.shell("""
17 echo A > A
18 echo B > B
19 git add A B
20 """)
22 model = main.MainModel(cwd=os.getcwd())
23 model.git.commit(m='commit test')
24 log = helper.pipe('git log --pretty=oneline | wc -l')
26 self.assertEqual(log.strip(), '1')
28 def test_git_config(self):
29 """Test cola.git.config()"""
30 self.shell('git config section.key value')
31 model = main.MainModel(cwd=os.getcwd())
32 value = model.git.config('section.key', get=True)
34 self.assertEqual(value, 'value')
36 # Test config_set
37 model.config_set('section.bool', True)
38 value = model.git.config('section.bool', get=True)
40 self.assertEqual(value, 'true')
41 model.config_set('section.bool', False)
43 # Test config_dict
44 config_dict = model.config_dict(local=True)
46 self.assertEqual(config_dict['section_key'], 'value')
47 self.assertEqual(config_dict['section_bool'], False)
49 # Test config_dict --global
50 global_dict = model.config_dict(local=False)
52 self.assertEqual(type(global_dict), dict)
55 if __name__ == '__main__':
56 unittest.main()