diff: move the search logic into the TextSearchWidget
[git-cola.git] / test / stash_model_test.py
blobff08c8b911edcae60a074b2dfebd291a260a7ca2
1 from __future__ import absolute_import, division, print_function, unicode_literals
3 # pylint: disable=redefined-outer-name
4 from cola.models.stash import StashModel
6 from . import helper
7 from .helper import app_context
10 # These assertions make flake8 happy. It considers them unused imports otherwise.
11 assert app_context is not None
14 def test_stash_info_for_message_without_slash(app_context):
15 helper.commit_files()
16 helper.write_file('A', 'change')
17 helper.run_git('stash', 'save', 'some message')
18 assert StashModel(app_context).stash_info()[0] == [
19 r'stash@{0}: On main: some message'
23 def test_stash_info_for_message_with_slash(app_context):
24 helper.commit_files()
25 helper.write_file('A', 'change')
26 helper.run_git('stash', 'save', 'some message/something')
27 model = StashModel(app_context)
28 stash_details = model.stash_info()[0]
29 assert stash_details == [r'stash@{0}: On main: some message/something']
32 def test_stash_info_on_branch_with_slash(app_context):
33 helper.commit_files()
34 helper.run_git('checkout', '-b', 'feature/a')
35 helper.write_file('A', 'change')
36 helper.run_git('stash', 'save', 'some message')
38 model = StashModel(app_context)
39 stash_info = model.stash_info()
41 stash_details = stash_info[0][0]
42 assert stash_details in (
43 'stash@{0}: On feature/a: some message',
44 # Some versions of Git do not report the full branch name
45 'stash@{0}: On a: some message',
48 stash_rev = stash_info[1][0]
49 assert stash_rev == r'stash@{0}'
51 stash_message = stash_info[3][0]
52 assert stash_message in (
53 'On feature/a: some message',
54 'On a: some message',