1 """Test interfaces used by the browser (git cola browse)"""
2 # pylint: disable=redefined-outer-name
3 from __future__
import absolute_import
, division
, print_function
, unicode_literals
6 from cola
import gitcmds
9 from .helper
import app_context
12 # These assertions make flake8 happy. It considers them unused imports otherwise.
13 assert app_context
is not None
16 def test_stage_paths_untracked(app_context
):
17 """Test stage_paths() with an untracked file."""
18 model
= app_context
.model
19 core
.makedirs('foo/bar')
20 helper
.touch('foo/bar/baz')
21 gitcmds
.add(app_context
, ['foo'])
22 app_context
.model
.update_file_status()
24 assert 'foo/bar/baz' in model
.staged
25 assert 'foo/bar/baz' not in model
.modified
26 assert 'foo/bar/baz' not in model
.untracked
29 def test_unstage_paths(app_context
):
30 """Test a simple usage of unstage_paths()."""
32 helper
.write_file('A', 'change')
33 helper
.run_git('add', 'A')
34 model
= app_context
.model
36 gitcmds
.unstage_paths(app_context
, ['A'])
39 assert 'A' not in model
.staged
40 assert 'A' in model
.modified
43 def test_unstage_paths_init(app_context
):
44 """Test unstage_paths() on the root commit."""
45 model
= app_context
.model
46 gitcmds
.unstage_paths(app_context
, ['A'])
49 assert 'A' not in model
.staged
50 assert 'A' in model
.untracked
53 def test_unstage_paths_subdir(app_context
):
54 """Test unstage_paths() in a subdirectory."""
55 helper
.run_git('commit', '-m', 'initial commit')
56 core
.makedirs('foo/bar')
57 helper
.touch('foo/bar/baz')
58 helper
.run_git('add', 'foo/bar/baz')
59 model
= app_context
.model
61 gitcmds
.unstage_paths(app_context
, ['foo'])
64 assert 'foo/bar/baz' in model
.untracked
65 assert 'foo/bar/baz' not in model
.staged