doc: v1.9.2 release notes draft
[git-cola.git] / test / test_cola_models_classic.py
blob13d924f305b1df2fe028630d4776a509ffd48b93
1 """Covers interfaces used by the classic view."""
2 import os
4 import helper
5 from cola import gitcmds
6 from cola.models.main import MainModel
9 class ClassicModelTestCase(helper.GitRepositoryTestCase):
10 """Tests interfaces used by the classic view."""
12 def setUp(self):
13 helper.GitRepositoryTestCase.setUp(self, commit=False)
14 self.model = MainModel(cwd=os.getcwd())
16 def test_everything(self):
17 """Test the MainModel.everything() method."""
18 self.shell('touch other-file')
19 everything = self.model.everything()
21 self.assertTrue('A' in everything)
22 self.assertTrue('B' in everything)
23 self.assertTrue('other-file' in everything)
25 def test_stage_paths_untracked(self):
26 """Test stage_paths() with an untracked file."""
27 self.shell("""
28 mkdir -p foo/bar &&
29 touch foo/bar/baz
30 """)
31 self.model.stage_paths(['foo'])
33 self.assertTrue('foo/bar/baz' in self.model.staged)
34 self.assertTrue('foo/bar/baz' not in self.model.modified)
35 self.assertTrue('foo/bar/baz' not in self.model.untracked)
37 def test_unstage_paths(self):
38 """Test a simple usage of unstage_paths()."""
39 self.shell("""
40 git commit -m'initial commit' > /dev/null
41 echo change > A &&
42 git add A
43 """)
44 gitcmds.unstage_paths(['A'])
45 self.model.update_status()
47 self.assertTrue('A' not in self.model.staged)
48 self.assertTrue('A' in self.model.modified)
50 def test_unstage_paths_init(self):
51 """Test unstage_paths() on the root commit."""
52 gitcmds.unstage_paths(['A'])
53 self.model.update_status()
55 self.assertTrue('A' not in self.model.staged)
56 self.assertTrue('A' in self.model.untracked)
58 def test_unstage_paths_subdir(self):
59 """Test unstage_paths() in a subdirectory."""
60 self.shell("git commit -m'initial commit' > /dev/null")
61 self.shell("""
62 mkdir -p foo/bar &&
63 touch foo/bar/baz &&
64 git add foo/bar/baz
65 """)
66 gitcmds.unstage_paths(['foo'])
67 self.model.update_status()
69 self.assertTrue('foo/bar/baz' in self.model.untracked)
70 self.assertTrue('foo/bar/baz' not in self.model.staged)