tests: update git-ops test for GitPython
[git-cola.git] / t / t0003-git-ops.py
blob66a169d49fcde8d2c6af5f069dade2370642516e
1 #!/usr/bin/env python
2 import os
3 import unittest
5 import testutils
6 from testutils import pipe
8 from ugit import models
10 class GitOpsTest(testutils.TestCase):
12 def testCommit(self):
13 self.shell("""
14 echo A > A
15 echo B > B
16 git init 2>&1 > /dev/null
17 git add A B
18 """)
20 model = models.Model()
21 model.commit(m="commit test")
22 log = pipe("git log --pretty=oneline | wc -l")
24 self.failUnless( '1' == log )
26 def testConfig(self):
27 self.shell("""
28 git init 2>&1 >/dev/null
29 git config section.key value
30 """)
31 model = models.Model()
32 value = model.config('section.key', get=True)
34 self.failUnless( value == 'value' )
36 # Test config_set
37 model.config_set('section.bool', True)
38 value = model.config('section.bool', get=True)
40 self.failUnless( value == 'true' )
41 model.config_set('section.bool', False)
43 # Test config_dict
44 config_dict = model.config_dict(local=True)
46 self.failUnless( config_dict['section_key'] == 'value' )
47 self.failUnless( config_dict['section_bool'] == False )
49 # Test config_dict --global
50 global_dict = model.config_dict(local=False)
52 self.failUnless( type(global_dict) is dict )
54 if __name__ == '__main__':
55 unittest.main()