2 """Tests basic git operations: commit, log, config"""
7 from cola
.main
.model
import MainModel
9 class ColaBasicGitTestCase(helper
.GitRepositoryTestCase
):
12 helper
.GitRepositoryTestCase
.setUp(self
, commit
=False)
14 def test_git_commit(self
):
15 """Test running 'git commit' via cola.git"""
22 model
= 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
= MainModel(cwd
=os
.getcwd())
32 value
= model
.git
.config('section.key', get
=True)
34 self
.assertEqual(value
, 'value')
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)
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__':