Merge branch 'dag-selection'
[git-cola.git] / test / browse_model_test.py
blobe93d5f149046b735f5837b6fa804a6e4fb0d040c
1 """Covers interfaces used by the classic view."""
2 from __future__ import unicode_literals
4 from cola import core
5 from cola import gitcmds
6 from cola.models.main import MainModel
8 from test import helper
11 class ClassicModelTestCase(helper.GitRepositoryTestCase):
12 """Tests interfaces used by the classic view."""
14 def setUp(self):
15 helper.GitRepositoryTestCase.setUp(self, commit=False)
16 self.model = MainModel(cwd=core.getcwd())
18 def test_stage_paths_untracked(self):
19 """Test stage_paths() with an untracked file."""
20 core.makedirs('foo/bar')
21 self.touch('foo/bar/baz')
22 self.model.stage_paths(['foo'])
24 self.assertTrue('foo/bar/baz' in self.model.staged)
25 self.assertTrue('foo/bar/baz' not in self.model.modified)
26 self.assertTrue('foo/bar/baz' not in self.model.untracked)
28 def test_unstage_paths(self):
29 """Test a simple usage of unstage_paths()."""
30 self.commit_files()
31 self.write_file('A', 'change')
32 self.git('add', 'A')
33 gitcmds.unstage_paths(['A'])
34 self.model.update_status()
36 self.assertTrue('A' not in self.model.staged)
37 self.assertTrue('A' in self.model.modified)
39 def test_unstage_paths_init(self):
40 """Test unstage_paths() on the root commit."""
41 gitcmds.unstage_paths(['A'])
42 self.model.update_status()
44 self.assertTrue('A' not in self.model.staged)
45 self.assertTrue('A' in self.model.untracked)
47 def test_unstage_paths_subdir(self):
48 """Test unstage_paths() in a subdirectory."""
49 self.git('commit', '-m', 'initial commit')
50 core.makedirs('foo/bar')
51 self.touch('foo/bar/baz')
52 self.git('add', 'foo/bar/baz')
53 gitcmds.unstage_paths(['foo'])
54 self.model.update_status()
56 self.assertTrue('foo/bar/baz' in self.model.untracked)
57 self.assertTrue('foo/bar/baz' not in self.model.staged)