1 """Test interfaces used by the browser (git cola browse)"""
2 # pylint: disable=redefined-outer-name
5 from cola
import gitcmds
8 from .helper
import app_context
11 # These assertions make pylint happy. It considers them unused imports otherwise.
12 assert app_context
is not None
15 def test_stage_paths_untracked(app_context
):
16 """Test stage_paths() with an untracked file."""
17 model
= app_context
.model
18 core
.makedirs('foo/bar')
19 helper
.touch('foo/bar/baz')
20 gitcmds
.add(app_context
, ['foo'])
21 app_context
.model
.update_file_status()
23 assert 'foo/bar/baz' in model
.staged
24 assert 'foo/bar/baz' not in model
.modified
25 assert 'foo/bar/baz' not in model
.untracked
28 def test_unstage_paths(app_context
):
29 """Test a simple usage of unstage_paths()."""
31 helper
.write_file('A', 'change')
32 helper
.run_git('add', 'A')
33 model
= app_context
.model
35 gitcmds
.unstage_paths(app_context
, ['A'])
38 assert 'A' not in model
.staged
39 assert 'A' in model
.modified
42 def test_unstage_paths_init(app_context
):
43 """Test unstage_paths() on the root commit."""
44 model
= app_context
.model
45 gitcmds
.unstage_paths(app_context
, ['A'])
48 assert 'A' not in model
.staged
49 assert 'A' in model
.untracked
52 def test_unstage_paths_subdir(app_context
):
53 """Test unstage_paths() in a subdirectory."""
54 helper
.run_git('commit', '-m', 'initial commit')
55 core
.makedirs('foo/bar')
56 helper
.touch('foo/bar/baz')
57 helper
.run_git('add', 'foo/bar/baz')
58 model
= app_context
.model
60 gitcmds
.unstage_paths(app_context
, ['foo'])
63 assert 'foo/bar/baz' in model
.untracked
64 assert 'foo/bar/baz' not in model
.staged