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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
"""Test Startup Dialog (git cola --prompt) Context Menu and related classes"""
from cola.widgets import startup
from .helper import app_context
# Prevent unused imports lint errors.
assert app_context is not None
def test_get_with_default_repo(app_context):
"""Test BuildItem::get for default repo"""
path = '/home/foo/git-cola'
name = 'git-cola'
mode = startup.ICON_MODE
is_bookmark = True
app_context.cfg.set_repo('cola.defaultrepo', path)
builder = startup.BuildItem(app_context)
actual = builder.get(path, name, mode, is_bookmark)
assert actual.path == path
assert actual.name == name
assert actual.mode == startup.ICON_MODE
assert actual.is_default
assert actual.is_bookmark
assert actual.text() == name
assert actual.isEditable()
def test_get_with_non_default_repo(app_context):
"""Test BuildItem::get for non-default repo"""
default_repo_path = '/home/foo/default_repo'
path = '/home/foo/git-cola'
name = 'git-cola'
mode = startup.ICON_MODE
is_bookmark = True
app_context.cfg.set_repo('cola.defaultrepo', default_repo_path)
builder = startup.BuildItem(app_context)
actual = builder.get(path, name, mode, is_bookmark)
assert actual.path == path
assert actual.name == name
assert not actual.is_default
assert actual.is_bookmark == is_bookmark
assert actual.text() == name
assert actual.isEditable()
def test_get_with_item_from_recent(app_context):
"""Test BuildItem::get for repository from recent list"""
path = '/home/foo/git-cola'
name = 'git-cola'
mode = startup.ICON_MODE
is_bookmark = False
app_context.cfg.set_repo('cola.defaultrepo', path)
builder = startup.BuildItem(app_context)
actual = builder.get(path, name, mode, is_bookmark)
assert actual.path == path
assert actual.name == name
assert actual.is_default
assert not actual.is_bookmark
assert actual.text() == name
assert actual.isEditable()
def test_get_with_list_mode(app_context):
"""Test BuildItem::get for list mode building"""
path = '/home/foo/git-cola'
name = 'git-cola'
mode = startup.LIST_MODE
is_bookmark = True
app_context.cfg.set_repo('cola.defaultrepo', path)
builder = startup.BuildItem(app_context)
actual = builder.get(path, name, mode, is_bookmark)
assert actual.path == path
assert actual.name == name
assert actual.is_default
assert actual.is_bookmark
assert actual.text() == path
assert not actual.isEditable()
|