test: Test the model's 'remotes' attribute
[git-cola.git] / test / test_cola_models_main.py
blobd094290820e5cb57084a394a40484d6da523d106
1 import helper
2 import os
4 from cola.models import main
6 class MainModelTestCase(helper.GitRepositoryTestCase):
7 """Tests the cola.models.main.MainModel class."""
9 def setUp(self):
10 helper.GitRepositoryTestCase.setUp(self, commit=True)
11 self.model = main.MainModel(cwd=os.getcwd())
12 self.model.use_worktree(os.getcwd())
14 def test_project(self):
15 """Test the 'project' attribute."""
16 project = os.path.basename(self.get_dir())
17 self.assertEqual(self.model.project, project)
19 def test_local_branches(self):
20 """Test the 'local_branches' attribute."""
21 self.model.update_status()
22 self.assertEqual(self.model.local_branches, ['master'])
24 def test_remote_branches(self):
25 """Test the 'remote_branches' attribute."""
26 self.model.update_status()
27 self.assertEqual(self.model.remote_branches, [])
29 self.shell("""
30 git remote add origin .
31 git fetch origin > /dev/null 2>&1
32 """)
33 self.model.update_status()
34 self.assertEqual(self.model.remote_branches, ['origin/master'])
36 def test_modified(self):
37 """Test the 'modified' attribute."""
38 self.shell('echo change > A')
39 self.model.update_status()
40 self.assertEqual(self.model.modified, ['A'])
42 def test_unstaged(self):
43 """Test the 'unstaged' attribute."""
44 self.shell('echo change > A')
45 self.shell('echo C > C')
46 self.model.update_status()
47 self.assertEqual(self.model.unstaged, ['A', 'C'])
49 def test_untracked(self):
50 """Test the 'untracked' attribute."""
51 self.shell('echo C > C')
52 self.model.update_status()
53 self.assertEqual(self.model.untracked, ['C'])
55 def test_remotes(self):
56 """Test the 'remote' attribute."""
57 self.shell('git remote add origin .')
58 self.model.update_status()
59 self.assertEqual(self.model.remotes, ['origin'])