1 """Test Startup Dialog (git cola --prompt) Context Menu and related classes"""
2 # pylint: disable=redefined-outer-name
4 from cola
.widgets
import startup
6 from .helper
import app_context
8 # These assertions make pylint happy. It considers them unused imports otherwise.
9 assert app_context
is not None
12 def test_get_with_default_repo(app_context
):
13 """Test BuildItem::get for default repo"""
14 path
= '/home/foo/git-cola'
16 mode
= startup
.ICON_MODE
19 app_context
.cfg
.set_repo('cola.defaultrepo', path
)
20 builder
= startup
.BuildItem(app_context
)
22 actual
= builder
.get(path
, name
, mode
, is_bookmark
)
24 assert actual
.path
== path
25 assert actual
.name
== name
26 assert actual
.mode
== startup
.ICON_MODE
27 assert actual
.is_default
28 assert actual
.is_bookmark
29 assert actual
.text() == name
30 assert actual
.isEditable()
33 def test_get_with_non_default_repo(app_context
):
34 """Test BuildItem::get for non-default repo"""
35 default_repo_path
= '/home/foo/default_repo'
36 path
= '/home/foo/git-cola'
38 mode
= startup
.ICON_MODE
41 app_context
.cfg
.set_repo('cola.defaultrepo', default_repo_path
)
42 builder
= startup
.BuildItem(app_context
)
44 actual
= builder
.get(path
, name
, mode
, is_bookmark
)
46 assert actual
.path
== path
47 assert actual
.name
== name
48 assert not actual
.is_default
49 assert actual
.is_bookmark
== is_bookmark
50 assert actual
.text() == name
51 assert actual
.isEditable()
54 def test_get_with_item_from_recent(app_context
):
55 """Test BuildItem::get for repository from recent list"""
56 path
= '/home/foo/git-cola'
58 mode
= startup
.ICON_MODE
61 app_context
.cfg
.set_repo('cola.defaultrepo', path
)
62 builder
= startup
.BuildItem(app_context
)
64 actual
= builder
.get(path
, name
, mode
, is_bookmark
)
66 assert actual
.path
== path
67 assert actual
.name
== name
68 assert actual
.is_default
69 assert not actual
.is_bookmark
70 assert actual
.text() == name
71 assert actual
.isEditable()
74 def test_get_with_list_mode(app_context
):
75 """Test BuildItem::get for list mode building"""
76 path
= '/home/foo/git-cola'
78 mode
= startup
.LIST_MODE
81 app_context
.cfg
.set_repo('cola.defaultrepo', path
)
82 builder
= startup
.BuildItem(app_context
)
84 actual
= builder
.get(path
, name
, mode
, is_bookmark
)
86 assert actual
.path
== path
87 assert actual
.name
== name
88 assert actual
.is_default
89 assert actual
.is_bookmark
90 assert actual
.text() == path
91 assert not actual
.isEditable()