models.main: Add a serialilzer to run generate_remote_helpers()
[git-cola.git] / test / test_cola_models_main.py
blob3cba996711c7df3567dfa2eed9bfbe78385f1ab1
1 import os
2 import unittest
4 import helper
5 from cola.models import main
8 class MainModelTestCase(helper.GitRepositoryTestCase):
9 """Tests the cola.models.main.MainModel class."""
11 def setUp(self):
12 helper.GitRepositoryTestCase.setUp(self)
13 self.model = main.MainModel(cwd=os.getcwd())
15 def test_project(self):
16 """Test the 'project' attribute."""
17 project = os.path.basename(self.test_path())
18 self.assertEqual(self.model.project, project)
20 def test_local_branches(self):
21 """Test the 'local_branches' attribute."""
22 self.model.update_status()
23 self.assertEqual(self.model.local_branches, ['master'])
25 def test_remote_branches(self):
26 """Test the 'remote_branches' attribute."""
27 self.model.update_status()
28 self.assertEqual(self.model.remote_branches, [])
30 self.shell("""
31 git remote add origin .
32 git fetch origin > /dev/null 2>&1
33 """)
34 self.model.update_status()
35 self.assertEqual(self.model.remote_branches, ['origin/master'])
37 def test_modified(self):
38 """Test the 'modified' attribute."""
39 self.shell('echo change > A')
40 self.model.update_status()
41 self.assertEqual(self.model.modified, ['A'])
43 def test_unstaged(self):
44 """Test the 'unstaged' attribute."""
45 self.shell('echo change > A')
46 self.shell('echo C > C')
47 self.model.update_status()
48 self.assertEqual(self.model.unstaged, ['A', 'C'])
50 def test_untracked(self):
51 """Test the 'untracked' attribute."""
52 self.shell('echo C > C')
53 self.model.update_status()
54 self.assertEqual(self.model.untracked, ['C'])
56 def test_remotes(self):
57 """Test the 'remote' attribute."""
58 self.shell('git remote add origin .')
59 self.model.update_status()
60 self.assertEqual(self.model.remotes, ['origin'])
62 def test_currentbranch(self):
63 """Test the 'currentbranch' attribute."""
64 self.shell('git checkout -b test > /dev/null 2>&1')
65 self.model.update_status()
66 self.assertEqual(self.model.currentbranch, 'test')
68 def test_tags(self):
69 """Test the 'tags' attribute."""
70 self.shell('git tag test')
71 self.model.update_status()
72 self.assertEqual(self.model.tags, ['test'])
75 if __name__ == '__main__':
76 unittest.main()