sequenceeditor: add docstrings
[git-cola.git] / test / browse_model_test.py
blob25c3fd8706674ac7840939d39939145b2c885a1b
1 """Test interfaces used by the browser (git cola browse)"""
2 # pylint: disable=redefined-outer-name
4 from cola import core
5 from cola import gitcmds
7 from . import helper
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()."""
30 helper.commit_files()
31 helper.write_file('A', 'change')
32 helper.run_git('add', 'A')
33 model = app_context.model
35 gitcmds.unstage_paths(app_context, ['A'])
36 model.update_status()
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'])
46 model.update_status()
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'])
61 model.update_status()
63 assert 'foo/bar/baz' in model.untracked
64 assert 'foo/bar/baz' not in model.staged