clone: clone into the parent directory by default
[git-cola.git] / test / startup_test.py
bloba2e89420355858b74d969495c832bc2f149b5b55
1 """Test Startup Dialog (git cola --prompt) Context Menu and related classes"""
2 from cola.widgets import startup
4 from .helper import app_context
6 # Prevent unused imports lint errors.
7 assert app_context is not None
10 def test_get_with_default_repo(app_context):
11 """Test BuildItem::get for default repo"""
12 path = '/home/foo/git-cola'
13 name = 'git-cola'
14 mode = startup.ICON_MODE
15 is_bookmark = True
17 app_context.cfg.set_repo('cola.defaultrepo', path)
18 builder = startup.BuildItem(app_context)
20 actual = builder.get(path, name, mode, is_bookmark)
22 assert actual.path == path
23 assert actual.name == name
24 assert actual.mode == startup.ICON_MODE
25 assert actual.is_default
26 assert actual.is_bookmark
27 assert actual.text() == name
28 assert actual.isEditable()
31 def test_get_with_non_default_repo(app_context):
32 """Test BuildItem::get for non-default repo"""
33 default_repo_path = '/home/foo/default_repo'
34 path = '/home/foo/git-cola'
35 name = 'git-cola'
36 mode = startup.ICON_MODE
37 is_bookmark = True
39 app_context.cfg.set_repo('cola.defaultrepo', default_repo_path)
40 builder = startup.BuildItem(app_context)
42 actual = builder.get(path, name, mode, is_bookmark)
44 assert actual.path == path
45 assert actual.name == name
46 assert not actual.is_default
47 assert actual.is_bookmark == is_bookmark
48 assert actual.text() == name
49 assert actual.isEditable()
52 def test_get_with_item_from_recent(app_context):
53 """Test BuildItem::get for repository from recent list"""
54 path = '/home/foo/git-cola'
55 name = 'git-cola'
56 mode = startup.ICON_MODE
57 is_bookmark = False
59 app_context.cfg.set_repo('cola.defaultrepo', path)
60 builder = startup.BuildItem(app_context)
62 actual = builder.get(path, name, mode, is_bookmark)
64 assert actual.path == path
65 assert actual.name == name
66 assert actual.is_default
67 assert not actual.is_bookmark
68 assert actual.text() == name
69 assert actual.isEditable()
72 def test_get_with_list_mode(app_context):
73 """Test BuildItem::get for list mode building"""
74 path = '/home/foo/git-cola'
75 name = 'git-cola'
76 mode = startup.LIST_MODE
77 is_bookmark = True
79 app_context.cfg.set_repo('cola.defaultrepo', path)
80 builder = startup.BuildItem(app_context)
82 actual = builder.get(path, name, mode, is_bookmark)
84 assert actual.path == path
85 assert actual.name == name
86 assert actual.is_default
87 assert actual.is_bookmark
88 assert actual.text() == path
89 assert not actual.isEditable()