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