1 """Test Startup Dialog (git cola --prompt) Context Menu and related classes"""
2 # pylint: disable=redefined-outer-name
3 from __future__
import absolute_import
, division
, print_function
, unicode_literals
5 from cola
.widgets
import startup
7 from .helper
import app_context
9 # These assertions make pylint happy. It considers them unused imports otherwise.
10 assert app_context
is not None
13 def test_get_with_default_repo(app_context
):
14 """Test BuildItem::get for default repo"""
15 path
= '/home/foo/git-cola'
17 mode
= startup
.ICON_MODE
20 app_context
.cfg
.set_repo('cola.defaultrepo', path
)
21 builder
= startup
.BuildItem(app_context
)
23 actual
= builder
.get(path
, name
, mode
, is_bookmark
)
25 assert actual
.path
== path
26 assert actual
.name
== name
27 assert actual
.mode
== startup
.ICON_MODE
28 assert actual
.is_default
29 assert actual
.is_bookmark
30 assert actual
.text() == name
31 assert actual
.isEditable()
34 def test_get_with_non_default_repo(app_context
):
35 """Test BuildItem::get for non-default repo"""
36 default_repo_path
= '/home/foo/default_repo'
37 path
= '/home/foo/git-cola'
39 mode
= startup
.ICON_MODE
42 app_context
.cfg
.set_repo('cola.defaultrepo', default_repo_path
)
43 builder
= startup
.BuildItem(app_context
)
45 actual
= builder
.get(path
, name
, mode
, is_bookmark
)
47 assert actual
.path
== path
48 assert actual
.name
== name
49 assert not actual
.is_default
50 assert actual
.is_bookmark
== is_bookmark
51 assert actual
.text() == name
52 assert actual
.isEditable()
55 def test_get_with_item_from_recent(app_context
):
56 """Test BuildItem::get for repository from recent list"""
57 path
= '/home/foo/git-cola'
59 mode
= startup
.ICON_MODE
62 app_context
.cfg
.set_repo('cola.defaultrepo', path
)
63 builder
= startup
.BuildItem(app_context
)
65 actual
= builder
.get(path
, name
, mode
, is_bookmark
)
67 assert actual
.path
== path
68 assert actual
.name
== name
69 assert actual
.is_default
70 assert not actual
.is_bookmark
71 assert actual
.text() == name
72 assert actual
.isEditable()
75 def test_get_with_list_mode(app_context
):
76 """Test BuildItem::get for list mode building"""
77 path
= '/home/foo/git-cola'
79 mode
= startup
.LIST_MODE
82 app_context
.cfg
.set_repo('cola.defaultrepo', path
)
83 builder
= startup
.BuildItem(app_context
)
85 actual
= builder
.get(path
, name
, mode
, is_bookmark
)
87 assert actual
.path
== path
88 assert actual
.name
== name
89 assert actual
.is_default
90 assert actual
.is_bookmark
91 assert actual
.text() == path
92 assert not actual
.isEditable()