2 """Tests basic git operations: commit, log, config"""
3 from __future__
import unicode_literals
8 from cola
.models
.main
import MainModel
10 from test
import helper
13 class ColaBasicGitTestCase(helper
.GitRepositoryTestCase
):
16 helper
.GitRepositoryTestCase
.setUp(self
, commit
=False)
18 def test_git_commit(self
):
19 """Test running 'git commit' via cola.git"""
20 self
.write_file('A', 'A')
21 self
.write_file('B', 'B')
22 self
.git('add', 'A', 'B')
24 model
= MainModel(cwd
=core
.getcwd())
25 model
.git
.commit(m
='commit test')
26 log
= self
.git('log', '--pretty=oneline')
28 self
.assertEqual(len(log
.splitlines()), 1)
30 def test_git_config(self
):
31 """Test cola.git.config()"""
32 self
.git('config', 'section.key', 'value')
33 model
= MainModel(cwd
=core
.getcwd())
34 value
= model
.git
.config('section.key', get
=True)
36 self
.assertEqual(value
, (0, 'value', ''))
39 model
.config_set('section.bool', True)
40 value
= model
.git
.config('section.bool', get
=True)
42 self
.assertEqual(value
, (0, 'true', ''))
43 model
.config_set('section.bool', False)
46 config_dict
= model
.config_dict(local
=True)
48 self
.assertEqual(config_dict
['section_key'], 'value')
49 self
.assertEqual(config_dict
['section_bool'], False)
51 # Test config_dict --global
52 global_dict
= model
.config_dict(local
=False)
54 self
.assertEqual(type(global_dict
), dict)
57 if __name__
== '__main__':