1 """Covers interfaces used by the browser (git cola browse)"""
2 from __future__
import absolute_import
, division
, unicode_literals
5 from cola
import gitcmds
10 class ClassicModelTestCase(helper
.GitRepositoryTestCase
):
11 """Tests interfaces used by the browser (git cola browse)"""
13 def test_stage_paths_untracked(self
):
14 """Test stage_paths() with an untracked file."""
15 core
.makedirs('foo/bar')
16 self
.touch('foo/bar/baz')
17 gitcmds
.add(self
.context
, ['foo'])
18 self
.model
.update_file_status()
20 self
.assertTrue('foo/bar/baz' in self
.model
.staged
)
21 self
.assertTrue('foo/bar/baz' not in self
.model
.modified
)
22 self
.assertTrue('foo/bar/baz' not in self
.model
.untracked
)
24 def test_unstage_paths(self
):
25 """Test a simple usage of unstage_paths()."""
27 self
.write_file('A', 'change')
28 self
.run_git('add', 'A')
29 gitcmds
.unstage_paths(self
.context
, ['A'])
30 self
.model
.update_status()
32 self
.assertTrue('A' not in self
.model
.staged
)
33 self
.assertTrue('A' in self
.model
.modified
)
35 def test_unstage_paths_init(self
):
36 """Test unstage_paths() on the root commit."""
37 gitcmds
.unstage_paths(self
.context
, ['A'])
38 self
.model
.update_status()
40 self
.assertTrue('A' not in self
.model
.staged
)
41 self
.assertTrue('A' in self
.model
.untracked
)
43 def test_unstage_paths_subdir(self
):
44 """Test unstage_paths() in a subdirectory."""
45 self
.run_git('commit', '-m', 'initial commit')
46 core
.makedirs('foo/bar')
47 self
.touch('foo/bar/baz')
48 self
.run_git('add', 'foo/bar/baz')
49 gitcmds
.unstage_paths(self
.context
, ['foo'])
50 self
.model
.update_status()
52 self
.assertTrue('foo/bar/baz' in self
.model
.untracked
)
53 self
.assertTrue('foo/bar/baz' not in self
.model
.staged
)