test: Add a testcase for gitcmds.untracked_files()
[git-cola.git] / test / test_cola_gitcmds.py
blob7d8a723fd05964ed808fd4fa7bb47d8d4002aace
1 import unittest
3 import helper
4 from cola import gitcmds
7 class GitCmdsTestCase(helper.GitRepositoryTestCase):
8 """Tests the cola.gitcmds module."""
9 def test_currentbranch(self):
10 """Test current_branch()."""
11 self.assertEqual(gitcmds.current_branch(), 'master')
13 def test_branch_list_local(self):
14 """Test branch_list(remote=False)."""
15 self.assertEqual(gitcmds.branch_list(remote=False), ['master'])
17 def test_branch_list_remote(self):
18 """Test branch_list(remote=False)."""
19 self.assertEqual(gitcmds.branch_list(remote=True), [])
20 self.shell("""
21 git remote add origin .
22 git fetch origin > /dev/null 2>&1
23 """)
24 self.assertEqual(gitcmds.branch_list(remote=True), ['origin/master'])
25 self.shell('git remote rm origin')
26 self.assertEqual(gitcmds.branch_list(remote=True), [])
28 def test_default_remote(self):
29 """Test default_remote()."""
30 self.assertEqual(gitcmds.default_remote(), None)
31 self.shell('git config branch.master.remote test')
32 self.assertEqual(gitcmds.default_remote(), 'test')
34 def test_tracked_branch(self):
35 """Test tracked_branch()."""
36 self.assertEqual(gitcmds.tracked_branch(), None)
37 self.shell("""
38 git config branch.master.remote test
39 git config branch.master.merge refs/heads/master
40 """)
41 self.assertEqual(gitcmds.tracked_branch(), 'test/master')
43 def test_tracked_branch_other(self):
44 """Test tracked_branch('other')."""
45 self.assertEqual(gitcmds.tracked_branch('other'), None)
46 self.shell("""
47 git config branch.other.remote test
48 git config branch.other.merge refs/heads/other/branch
49 """)
50 self.assertEqual(gitcmds.tracked_branch('other'), 'test/other/branch')
52 def test_untracked_files(self):
53 """Test untracked_files()."""
54 self.shell('touch C D E')
55 self.assertEqual(gitcmds.untracked_files(), ['C', 'D', 'E'])
58 if __name__ == '__main__':
59 unittest.main()