1 """Covers interfaces used by the classic view."""
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."""
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."""
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()."""
40 git commit -m'initial commit' > /dev/null
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")
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
)