extras: pylint updates
[git-cola.git] / test / browse_model_test.py
blobb14161553b69c8e812b3fcbb4c98789ca3160c2e
1 """Covers interfaces used by the browser (git cola browse)"""
2 from __future__ import absolute_import, division, unicode_literals
4 from cola import core
5 from cola import gitcmds
6 from cola.models.main import MainModel
8 from . import helper
11 class ClassicModelTestCase(helper.GitRepositoryTestCase):
12 """Tests interfaces used by the browser (git cola browse)"""
14 def test_stage_paths_untracked(self):
15 """Test stage_paths() with an untracked file."""
16 core.makedirs('foo/bar')
17 self.touch('foo/bar/baz')
18 gitcmds.add(self.context, ['foo'])
19 self.model.update_file_status()
21 self.assertTrue('foo/bar/baz' in self.model.staged)
22 self.assertTrue('foo/bar/baz' not in self.model.modified)
23 self.assertTrue('foo/bar/baz' not in self.model.untracked)
25 def test_unstage_paths(self):
26 """Test a simple usage of unstage_paths()."""
27 self.commit_files()
28 self.write_file('A', 'change')
29 self.run_git('add', 'A')
30 gitcmds.unstage_paths(self.context, ['A'])
31 self.model.update_status()
33 self.assertTrue('A' not in self.model.staged)
34 self.assertTrue('A' in self.model.modified)
36 def test_unstage_paths_init(self):
37 """Test unstage_paths() on the root commit."""
38 gitcmds.unstage_paths(self.context, ['A'])
39 self.model.update_status()
41 self.assertTrue('A' not in self.model.staged)
42 self.assertTrue('A' in self.model.untracked)
44 def test_unstage_paths_subdir(self):
45 """Test unstage_paths() in a subdirectory."""
46 self.run_git('commit', '-m', 'initial commit')
47 core.makedirs('foo/bar')
48 self.touch('foo/bar/baz')
49 self.run_git('add', 'foo/bar/baz')
50 gitcmds.unstage_paths(self.context, ['foo'])
51 self.model.update_status()
53 self.assertTrue('foo/bar/baz' in self.model.untracked)
54 self.assertTrue('foo/bar/baz' not in self.model.staged)