1 """Test interfaces used by the browser (git cola browse)"""
3 from cola
import gitcmds
6 from .helper
import app_context
9 # Prevent unused imports lint errors.
10 assert app_context
is not None
13 def test_stage_paths_untracked(app_context
):
14 """Test stage_paths() with an untracked file."""
15 model
= app_context
.model
16 core
.makedirs('foo/bar')
17 helper
.touch('foo/bar/baz')
18 gitcmds
.add(app_context
, ['foo'])
19 app_context
.model
.update_file_status()
21 assert 'foo/bar/baz' in model
.staged
22 assert 'foo/bar/baz' not in model
.modified
23 assert 'foo/bar/baz' not in model
.untracked
26 def test_unstage_paths(app_context
):
27 """Test a simple usage of unstage_paths()."""
29 helper
.write_file('A', 'change')
30 helper
.run_git('add', 'A')
31 model
= app_context
.model
33 gitcmds
.unstage_paths(app_context
, ['A'])
36 assert 'A' not in model
.staged
37 assert 'A' in model
.modified
40 def test_unstage_paths_init(app_context
):
41 """Test unstage_paths() on the root commit."""
42 model
= app_context
.model
43 gitcmds
.unstage_paths(app_context
, ['A'])
46 assert 'A' not in model
.staged
47 assert 'A' in model
.untracked
50 def test_unstage_paths_subdir(app_context
):
51 """Test unstage_paths() in a subdirectory."""
52 helper
.run_git('commit', '-m', 'initial commit')
53 core
.makedirs('foo/bar')
54 helper
.touch('foo/bar/baz')
55 helper
.run_git('add', 'foo/bar/baz')
56 model
= app_context
.model
58 gitcmds
.unstage_paths(app_context
, ['foo'])
61 assert 'foo/bar/baz' in model
.untracked
62 assert 'foo/bar/baz' not in model
.staged