forked from git-cola/git-cola
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbrowse_model_test.py
57 lines (44 loc) · 1.93 KB
/
browse_model_test.py
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
"""Covers interfaces used by the classic view."""
from __future__ import absolute_import, division, unicode_literals
from cola import core
from cola import gitcmds
from cola.models.main import MainModel
from test import helper
class ClassicModelTestCase(helper.GitRepositoryTestCase):
"""Tests interfaces used by the classic view."""
def setUp(self):
helper.GitRepositoryTestCase.setUp(self, commit=False)
self.model = MainModel(cwd=core.getcwd())
def test_stage_paths_untracked(self):
"""Test stage_paths() with an untracked file."""
core.makedirs('foo/bar')
self.touch('foo/bar/baz')
self.model.stage_paths(['foo'])
self.assertTrue('foo/bar/baz' in self.model.staged)
self.assertTrue('foo/bar/baz' not in self.model.modified)
self.assertTrue('foo/bar/baz' not in self.model.untracked)
def test_unstage_paths(self):
"""Test a simple usage of unstage_paths()."""
self.commit_files()
self.write_file('A', 'change')
self.git('add', 'A')
gitcmds.unstage_paths(['A'])
self.model.update_status()
self.assertTrue('A' not in self.model.staged)
self.assertTrue('A' in self.model.modified)
def test_unstage_paths_init(self):
"""Test unstage_paths() on the root commit."""
gitcmds.unstage_paths(['A'])
self.model.update_status()
self.assertTrue('A' not in self.model.staged)
self.assertTrue('A' in self.model.untracked)
def test_unstage_paths_subdir(self):
"""Test unstage_paths() in a subdirectory."""
self.git('commit', '-m', 'initial commit')
core.makedirs('foo/bar')
self.touch('foo/bar/baz')
self.git('add', 'foo/bar/baz')
gitcmds.unstage_paths(['foo'])
self.model.update_status()
self.assertTrue('foo/bar/baz' in self.model.untracked)
self.assertTrue('foo/bar/baz' not in self.model.staged)